for loop not working
Ältere Kommentare anzeigen
Hi, I have this signal and I want to find out the mean between the peaks. I know the x and y values at the peaks. this is my code
y1=locs+10; %wants few points before and after peaks to avoid mean being affected by the peak values thus +10
y2=locs-10; %locs is the y position of the peaks
for k= 1:length(locs)-1
ROI=transpose(y1(k):y2(k+1)); %transpose is the whole signal, trying to extract each region between peaks
mean2=mean(ROI);
end
The code works for one loop (i.e.k=1) but wont repeat it. But if I use 'ROI=transpose(y1(k):y2(k+1))' in the command window and physically type k=2 and 3 it will work. so I guess i'm missing a step in the for loop. any suggestions would be appreciated. Thanks in advance

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Descriptive Statistics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!