How do I find the local maxima of a vector?

16 views (last 30 days)
There does not seem to be a function for this.

Accepted Answer

Doug Hull
Doug Hull on 18 Jan 2011
You can use the following one-line function to determine the indices of the local maxima.
function index = localmax(x)
index = find( diff( sign( diff([0; x(:); 0]) ) ) < 0 );
[from the MATLAB FAQ of Ancient Times]

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!