# 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' (Default: eps)
• 'MinPeakDistance' (Default: 1)
• 'MinPeakWidth' (Default: 1)
• '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.

'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.