How to use findpeaks to only find specific peaks and time where they occurred?

38 次查看(过去 30 天)
I'm attaching a plot of voltage versus time for a signal that I averaged over time. I want to use the findpeaks function to exclude the major peak seen at approx 40 ms, as well as the repetitive downward inflections that repeat. I just want the peakfinder function to automatically locate the inflection I've circled in yellow. Is there a way to find the magnitude of this peak and the time where it occurred, using the findpeaks function? Any other tips to automate this would be welcome as well!
Capture.JPG
  3 个评论
Zuha Yousuf
Zuha Yousuf 2019-12-22
Thank you so much for your answer! I am a little confused about where you explained detecting the peaks I dont want. The code I wrote is as follows:
[peaks_noise,locs_noise,w_noise,proms_noise]=findpeaks(-signal,'MinPeakHeight',2.42e-5,'MinPeakDistance',16.7);
This outputs all the info about the peaks that I don't want.
You next said that I need to run findpeaks with MinPeakHeight to find the peak that I do want. Is there a way to eliminate the unwanted peaks I previously found from this signal, and then run findpeaks on a new cleaned signal to just locate this peak that I want? Since the findpeaks only outputs the locations and magnitudes of the peaks.
Image Analyst
Image Analyst 2019-12-22
编辑:Image Analyst 2019-12-22
And what was wrong about simply finding and erasing the big two peaks that you don't want before finding the smaller ones, like I showed you in my Answer below? What you just suggested was just what I had shown you an hour before you posted.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2019-12-22
Why can't you just erase everything before 50 ms and then find peaks?
index = find(t < 50, 1, 'last');
amplitude(1:index = 0);
[peakValues, locations] = findpeaks(amplitude);
Or if it's not always there at 50 or so, find the min point and go up until it hits the mean (about -2)
[~, index] = min(amplitude);
meanAmp = mean(amplitude)
while amplitude(index) < meanAmp
index = index + 1;
end
amplitude(1:index = 0);
[peakValues, locations] = findpeaks(amplitude);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by