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

38 views (last 30 days)
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 Comments
Zuha Yousuf
Zuha Yousuf on 22 Dec 2019
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 on 22 Dec 2019
Edited: Image Analyst on 22 Dec 2019
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.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 22 Dec 2019
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!