for loop not working
显示 更早的评论
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

采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!