Fast Local Extrema

Version 6.0.0 (1.08 KB) by Moreno, M.
Fast local extrema calculation
30 Downloads
Updated 20 Apr 2022

View License

Calling x = extrema(X) returns a logical array whose elements are 1 (true) when a local extrema is detected in the corresponding element of 'X'. The function operates along the columns of 'X'. An example of the use of this function is:
t = 2 * pi * (0 : 1 / (1000 - 1) : 1)';
X = [t, exp(-t / 2) .* sin(10 * t)];
k = extrema(X(:, 2));
figure
hold on
plot(X(:, 1), X(:, 2))
plot(X(k, 1), X(k, 2), 'o')
axis equal

Cite As

Moreno, M. (2024). Fast Local Extrema (https://www.mathworks.com/matlabcentral/fileexchange/108134-fast-local-extrema), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
6.0.0

Corrections and improvements kindly suggested by Jan (see discussions)

5.0.0

Faster differentiation

4.0.0

Deletion of all intermediate variables

3.0.0

Speed boost by removal of an intermediate variable

2.0.0

Avoided array conversion from double to logical

1.0.0