MATLAB: Exclude last sample as peak despite being the maximum

findpeaksplot

The first sample is excluded despite being the maximum in findpeaks(). How to exclude the last peak?

Best Answer

The findpeaks function has a number of name-value pair arguments you can use. For example, if you only want one peak (the first one that meets other criteria you may set), set 'NPeaks',1 in the argument list. Others you can set that might do what you want are 'MinPeakDistance' and 'Threshold'.