Code covered by the BSD License
by Luigi Piegari
16 Dec 2009
This function gives the local maxima of the input signal: x.
| Watch this File
The function is very easy to be used. One tunable parameter allows it to be adapted to very different applications. It should work with any Matlab version.
It looks like you forgot an "any":
"if x(n) > [x(minimo_ind:n-1) x(n+1:massimo_ind)]"
should be "if any( x(n) > [x(minimo_ind:n-1) x(n+1:massimo_ind)] )"
Also, you could better use the construction
M = NaN(size(x)); for (...) ... if any(...) M(n) = x(n); end end M = M(~isnan(M));
which, despite the extra initializations and deletions should be faster (and safer) for long [x] or small [punti], or [x] with lots of local maxima.
Contact us at files@mathworks.com