# 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.
Type: double
Dimension: vector
property
A control on the identification of peaks. See Comments.
The available options are as follows:
• 'MinPeakHeight'
• 'MinPeakDistance'
• 'MinPeakWidth'
• 'DoubleSided'
Type: string
value
The value associated with the preceeding property.
Type: double
Dimension: scalar

## Outputs

pks
The peak values.
Type: double
Dimension: vector
idx
The indices at which the peaks are found.
Type: double
Dimension: vector
extra
Extra information related to peak widths based on fitted parabolas. See Comments.
Type: struct
• parabol: a struct containing polynomial fitting information.
• height: the estimated heights of the peaks.
• baseline: the height at which the widths are estimated.
• roots: the index locations at which the parabolas intersect the baseline.

## 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

'MinPeakHeight' sets the peak height threshold. The default is eps.

'MinPeakDistance' sets the neighborhood threshold in units of sample counts. Starting with the highest peak, other peaks within the specified half interval are ignored. The default is 4. Use 0 to disable this threshold.

'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. The default is 4. Use 0 to disable this threshold.

'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 presense of noise, parabola fitting to estimate peak widths is sensitive to the values associated with the'MinPeakDistance'. A poor fit may cause peaks to be omitted from the result.