findpeaks
Locate the peaks of a signal.
Syntax
[pks,idx,extra] = findpeaks(signal)
[pks,idx,extra] = findpeaks(signal,property,value,...)
[pks,idx,extra] = findpeaks(...,'DoubleSided')
Inputs
- signal
- The signal data, typically sampled at a constant rate.
- property
- A control on the identification of peaks. See Comments.
- value
- The value associated with the preceeding property.
Outputs
- pks
- The peak values.
- idx
- The indices at which the peaks are found.
- extra
- Extra information related to peak widths based on fitted parabolas. See Comments.
Examples
[pks,loc] = findpeaks([2,5,6,8,3,9,6,4,6,12,2,6,8,10,5],'MinPeakHeight',7,'MinPeakWidth',0)
pks = [Matrix] 1 x 3
9 12 10
loc = [Matrix] 1 x 3
6 10 14
Comments
'MinPeakHeight' sets the peak height threshold.
'MinPeakDistance' sets the neighborhood threshold in units of sample counts. Starting with the highest peak, other peaks within the specified half interval are ignored.
'MinPeakWidth' sets the width threshold in units of sample counts. For each peak, a parabola is fitted to the points in its neighboorhood based on 'MinPeakDistance'. The width is then measured halfway between the peak height and the MinPeakHeight value. Peaks with widths narrower than the threshold are ignored.
'DoubleSided' indicates that data has positive and negative values, and that both positive and negative peaks are desired. For this property, there is no associated 'value' argument that follows and the 'MinPeakHeight' is relative to the mean.
extra.parabol is a struct containing matrices x and pp. x contains the indices in the neighborhood of each peak on which the parabola is fitted, and pp contains the parabola coefficients.
extra.baseline is the mean of each peak and the 'MinPeakHeight' threshold.
In the presence of noise, parabola fitting to estimate peak widths is sensitive to the values associated with 'MinPeakDistance'. A poor fit might cause peaks to be omitted from the result.