How do I find the local maxima of a vector?

 Accepted Answer

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)

Categories

Products

Tags

Community Treasure Hunt

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

Start Hunting!