findpeaks

Find local maxima

Syntax

pks = findpeaks(data)
[pks,locs] = findpeaks(data)
[...] = findpeaks(data,'minpeakheight',mph)
[...] = findpeaks(data,'minpeakdistance',mpd)
[...] = findpeaks(data,'threshold',th)
[...] = findpeaks(data,'npeaks',np)
[...] = findpeaks(data,'sortstr',str)

Description

pks = findpeaks(data)finds local maxima
or peakspksin the inputdata.datamust
be a row or column vector with real-valued elements and have a minimum
length of three.findpeakscompares each element
ofdatato its neighboring values. If an element
ofdatais larger than both of its neighbors, it
is alocal peak. If there are no local maxima,pksis
an empty vector.

[pks,locs] = findpeaks(data)returns the
indices of the peaks.

[...] = findpeaks(data,'minpeakheight',mph)returns
only peaks that exceed the real-valued scalarmph.mphdefaults
to-Inf.

[...] = findpeaks(data,'minpeakdistance',mpd)returns
only peaks with indices separated by more than the positive integermpd.mpddefaults
to 1.

[...] = findpeaks(data,'threshold',th)returns
only peaks that exceed their neighbors by greater than the nonnegative
real scalarth.thdefaults
to 0.

[...] = findpeaks(data,'npeaks',np)returns
a maximum number of peaksnp.findpeaksoperates
from the first element ofdataand terminates when
the number of peaks reachesnp. By default,findpeaksreturns
all peaks meeting your criteria.

[...] = findpeaks(data,'sortstr',str)returns
peaks in the order specified by the stringstr.'ascend'returns
peaks ordered from smallest to largest.'descend'returns
peaks ordered from largest to smallest.'none'is
the default and returns peaks in the order in which they occur indata.

Examples

Find peaks in a vector:

data = [2 12 4 6 9 4 3 1 19 7];
pks=findpeaks(data);
% returns the 1x3 vector [12 9 19];
 

Find peaks separated by more than three elements and return
their locations:

data = [2 12 4 6 9 4 3 1 19 7];
[pks,locs]=findpeaks(data,'minpeakdistance',3);
% returns pks=[12 19]
% locs=[2 9]

标签: none

评论已关闭