Stuck on findpeaks 'MinPeakDistance' Error

12 views (last 30 days)
William Popov
William Popov on 6 Aug 2015
Answered: Rob Callan on 9 Aug 2015
I'm using the findpeaks function to process some data from a pressure sensor and I'm getting an odd error for which I can't find the cause. My code is as follows:
mean_pressure_reading=mean(particular_trial(:,2:end),2);
z=mean_pressure_reading;
min_peak_prominence=0.4*max(mean_pressure_reading);
timestamp_column=particular_trial(:,1);
x=timestamp_column;
[pks,locs,w,p]=findpeaks(z,50,'MinPeakProminence',min_peak_prominence,'MinPeakDistance',3);
The error I get is as follows:
Error using findpeaks
Expected MinPeakDistance to be a scalar with value < 2.7.
Error in findpeaks>parse_inputs (line 318)
validateattributes(Pd,{'numeric'},{'real','scalar','nonempty','nonnegative','<',x(M)-x(1)},'findpeaks','MinPeakDistance');
Error in findpeaks (line 131)
[y,yIsRow,x,xIsRow,minH,minP,minW,maxW,minD,minT,maxN,sortDir,annotate,refW] ...
Error in lunge_splitter (line 59)
[pks,locs,w,p]=findpeaks(z,50,'MinPeakProminence',min_peak_prominence,'MinPeakDistance',2.71);
I don't understand why the MinPeakDistance value is limited to <2.7 Could someone please explain this error and how I can get around it? The data is such that there are relevant peaks with greater separation than 2.7, so having this work would make the data analysis go much more smoothly.
Thanks.

Answers (1)

Rob Callan
Rob Callan on 9 Aug 2015
It seems unlikely to apply to your particular error, but it looks like findpeaks requires length(z) > minpeakdistance.

Community Treasure Hunt

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

Start Hunting!