MATLAB: How to find the local maxima of a vector

MATLABmaximum

There does not seem to be a function for this.

Best 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]
Related Question