Main Content

Find Local Extrema

Find local maxima and minima in the Live Editor

Description

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.

  • Visualize the detected extrema.

Find Local Extrema task in the Live Editor

Open the Task

To add the Find Local Extrema task to a live script in the MATLAB Live Editor:

  • On the Live Editor tab, click Task and select the Find Local Extrema icon .

  • In a code block in the live script, type a relevant keyword, such as extrema or find. Select Find Local Extrema from the suggested command completions.

Parameters

This task operates on input data contained in a vector, table, or timetable. The data can be of type single, double, logical, or signed or unsigned integer types such as int64.

When providing a table or timetable for the input data, select All supported variables to operate on all variables with a supported type. Select All numeric variables to operate on all variables of type single or double, or signed or unsigned integer types. To choose specific supported variables to operate on, select Specified variables and then select the variables individually.

Specify a flat region indicator when you have local consecutive extrema values.

MethodDescription
CenterIndicates only the center element of a flat region as the local extrema
FirstIndicates only the first element of a flat region as the local extrema
LastIndicates only the last element of a flat region as the local extrema
AllIndicates all the elements of a flat region as the local extrema

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.

Specify a prominence window type and size to define a window of neighboring points for which to compute the prominence for each local extrema.

WindowDescription
CenteredSpecified window length centered about the current point
AsymmetricSpecified 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.

Version History

Introduced in R2019b

expand all