Find peaks in a certain time interval
17 views (last 30 days)
Show older comments
Hi everyone, i need your help :)
I have a real signal (called signal) with the relative time vector (called time) in which i have already found the major peaks:
M=max(signal);
[p,l]=findpeak(signal);
j = 1;
i = 1;
s = size(p,1);
for i = 1:s
if p(i) >= mn
peak (j) = p(i);
lock (j) = l(i);
j = j+1;
end
end
Now, i have to discharge the peaks which are detected in a distance lower than 0.5 s. and this point is where i have some issue, Because i don't know how to select the peaks starting by the location and the associate time.
I don't know if i am clear, if you need some more info im totally available, Someone can help me ?
1 Comment
dpb
on 25 Jun 2021
Why don't you first investigate the various options available in findpeaks to screen peaks based on given criteria?
[p,l]=findpeaks(signal,t,'MinPeakDistance',0.5);
will not reutrn peaks within 500 msec of each other for you -- you must pass the time vector in the units in which the spacing distance is entered, here I assumed seconds.
Also, it is not good practice to use time as a variable; that aliases the builtin MATLAB time function; I used t above instead.
You'll want to plot the result and compare to ensure you're not filtering out those that you do want, but there's where I'd certainly suggest to start...
You may want to use other criteria instead or besides to refine the returned peaks before you begin writing searching code of your own...
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!