| Signal Processing Toolbox™ | ![]() |
pks = findpeaks(x)
[pks,locs] = findpeaks(x)
[...] = findpeaks(x,'minpeakheight',mph)
[...] = findpeaks(x,'minpeakdistance',mpd)
[...] = findpeaks(x,'threshold',th)
[...] = findpeaks(x,'npeaks',np)
[...] = findpeaks(x,'sortstr',str)
pks = findpeaks(x) finds local maxima or peaks in x. Each value of x is compared to its neighboring values, and if it is larger than both of its neighbors, it is a local peak and is returned in the vector pks. If no peaks are found, findpeaks returns an empty vector.
[pks,locs] = findpeaks(x) returns, in the locs vector, the location index of each peak in x.
[...] = findpeaks(x,'minpeakheight',mph) returns only peaks that are greater than the minimum peak height mph, where mph is a real, scalar value. Default for mph is -Inf. Setting the minimum peak height may reduce the number of peaks returned and the overall processing time.
[...] = findpeaks(x,'minpeakdistance',mpd) returns only peaks that are separated by the minimum peak distance mpd. The minimum peak distance is a positive integer that specifies the number of data values to ignore around a peak in x. Setting the minimum peak distance ignores smaller peaks that may occur close to larger local peaks. For example, if a large local peak occurs at N, any other peaks in (N-mpd, N+mpd) are ignored. Default for mpd is 1.
[...] = findpeaks(x,'threshold',th) returns only peaks that are greater than their neighbors by at least the threshold th, which is a real, scalar value and is greater than or equal to 0. Default for th is 0.
[...] = findpeaks(x,'npeaks',np) returns a maximum of np number of peaks. When np peaks are found, the search stops. Default is to return all peaks.
[...] = findpeaks(x,'sortstr',str) specifies the sorting order, where str is 'ascend', 'descend' or 'none'. For 'ascend', the peaks are returned in order from smallest to largest, and vice versa for 'descend'. For 'none', the peaks are returned in the order in which they occur in x.
x = [2 12 4 6 9 4 3 1 19 7];
pks = findpeaks(x)
pks =
12 9 19
pks = findpeaks(x,'threshold',6)
pks =
12 19
pks = findpeaks(x,'threshold',6,'sortstr','descend')
pks =
19 12
![]() | filtstates.dfiir | fir1 | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |