Code covered by the BSD License  

Highlights from
Local Maxima finder

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 1.4 KB File ID: #26115

Local Maxima finder

by Luigi Piegari

 

16 Dec 2009

This function gives the local maxima of the input signal: x.

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
19 Dec 2009 Rody Oldenhuis

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.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matlab Luigi Piegari 16 Dec 2009 09:53:17
max Luigi Piegari 16 Dec 2009 09:53:17
matlab Hyeokjune Jeon 30 Dec 2009 03:19:21

Contact us at files@mathworks.com