Q: Finding peaks in matlab in flat regions I have data in an array in matlab. I want to find peaks, but faced the following problem shown in the picture below.
To generate peaks and plot them I used the following code:
gyryMF = medfilt1(gyry, 3);
[pks, gyryPeaks] = findpeaks(gyryMF);
%%
plot(gyryMF);
text(gyryPeaks+.02,pks,num2str((1:numel(pks))')); 


As you see from picture, some peaks not found, because there is a flat region. I wonder if somehow I can find and include them as well?

A: How about writing your own peaks function with your own criteria?
peak_no = []
ind_peak_no = []
if  Data(x) < Data(x+1) &&  Data(x+1) > Data(x+2) && Data(x+1)> Peak_min
      peak_no = [peak_no;Data(x+1)];
      ind_peak_no = [ind_peak_no; x+1];
end
