Find local maxima and minima in the Live Editor
The Find Local Extrema task lets you interactively find local maxima and local minima in data. The task automatically generates MATLAB® code for your live script.
Using this task, you can:
Find local maxima, minima, or both in data from a workspace variable.
Adjust parameters to locate fewer or more extrema.
Automatically visualize the detected extrema.
To add the Find Local Extrema task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Find Local Extrema.
In a code block in the script, type a relevant keyword, such as
find. Select Find Local
Extrema from the suggested command completions.
Flat selection— Flat region indicator
Specify a flat region indicator when you have local consecutive extrema values.
|Indicates only the center element of a flat region as the local extrema.|
|Indicates only the first element of a flat region as the local extrema.|
|Indicates only the last element of a flat region as the local extrema.|
|Indicates all the elements of a flat region as the local extrema.|
Min. prominence— Minimum prominence of extrema
0(default) | positive scalar | ...
Specify a minimum prominence to return only local extrema whose prominence is at least that value. Higher prominence values return fewer detected extrema.
The prominence of a local maximum (or peak) is a measure of how the peak stands out with respect to its height and location relative to other peaks. The prominence of a local minimum (or valley) is a measure of how the valley stands out with respect to its depth and location relative to other valleys.
Prominence window— Window for computing prominence
Specify a prominence window type and size to define a window of neighboring points for which to compute the prominence for each local extrema.
|Specified window length centered about the current point.|
|Specified window containing the number of elements before the current point and the number of elements after the current point.|
Window sizes are relative to the X-axis variable units.