How to create a vector?

6 Ansichten (letzte 30 Tage)
Ioana Mateescuu
Ioana Mateescuu am 21 Jan. 2019
Kommentiert: Stephen23 am 22 Jan. 2019
How can I create a vector containing all the k values? Thank you!
beat_count=0;
for k=2:length(val)-1;
if(val(k)>val(k-1)&val(k)>val(k+1)&val(k)>1)
k
disp('Prominant peak found');
beat_count=beat_count+1;
end
end

Akzeptierte Antwort

Kevin Phung
Kevin Phung am 21 Jan. 2019
v = [];
for k=2:length(val)-1;
if(val(k)>val(k-1)&val(k)>val(k+1)&val(k)>1)
k
disp('Prominant peak found');
beat_count=beat_count+1;
v(end+1) = k % save k value into vector v;
end
end

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2007b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by