How to detect the maximums of a signal, Cómo detectar los maximos de una señal
Show older comments
Hi!! I need a code which detects all de maximums of a signal. This signal has clear peaks, so I would like to know their position.
I have tried this, but the result is not the expected one:
function index_max = PRUEBAMAXIMO(x)
[lloc, tamany] = size(x);
index_max = zeros(1,2);
for(i=0:tamany-2)
if(x(i+1)>x(i+2))
index_max(1) = i;
i = tamany-1;
end
end
for (s=index_max(1):tamany-3)
if(x(s+1) < x(s+2)) %si se da esto, esporque empieza la subida
s_subida = s;
for (k=s_subida:tamany-3)
if(x(s+1) > x(s+2))
index_max(2)=s;
k = tamany -3; %//para salir del for
s = tamany-3; %//para salir del for
end
end
end
end
THANK YOU VERY MUCH IN ADVANCED % % end
Thank you very much
1 Comment
Mahdi
on 16 Apr 2013
Have you looked into the findpeaks() function to see if it helps give you the solution that you want?
Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!