islocalmax
Marks the local maxima of a vector.
Category: Data Import and Analysis > Preprocessing Data
Syntax
TF = islocalmax(A)
true where an element is larger than its neighbors.
[TF, P] = islocalmax(A)
Also returns the prominence of each peak.
TF = islocalmax(A, 'MinProminence', m)
Keeps only peaks whose prominence is at least m.
Description
A local maximum is a point strictly greater than the neighbors on both sides. Prominence measures how far a peak rises above the lowest contour that separates it from a higher peak, so it filters out small ripples caused by noise.
Use find(TF) to get the positions of the peaks.
Input arguments
A- Numeric vector or matrix (columns are analyzed).
'MinProminence'- Minimum height a peak must stand above its surroundings.
Output arguments
TF- Logical array the size of
A. P- Prominence values, zero at points that are not peaks.
Example
Peaks and prominence
x = [1 3 1 4 1];
[tf, p] = islocalmax(x)
islocalmax(x, 'MinProminence', 3)
Output
tf = 1×5 logical array
0 1 0 1 0
p = 1×5
0 2 0 3 0
ans = 1×5 logical array
0 0 0 1 0