This can easily be solved using findpeaks
from the Signal Processing Toolbox. Specifically, for your data I had to call it this way:
[pks, locs] = findpeaks(max(vec)-vec, 'minpeakdistance', 160, 'minpeakheight', 22);
findpeaks
only finds positive peaks (local maxima). As such, what we need to do is invert this so that all of the local minima become local maxima. I did this by taking the maximum value of the vector and subtracting with the vector. Because there are so many local peaks, the minpeakdistance
field allows you to find peaks that are at least separated by this much in between each peak. I tuned this to 160. Also, the minimum peak height finds peaks that are greater than a certain number, which I tuned to be 22. pks
finds the actual peak values and locs
gives you the locations of the peaks in your signal. We need to use locs
to find the actual peak data because we performed this on the mirror reflected version of your signal. As such, to get the actual peak data, do this:
pks_final = vecs(loc);
As a demonstration, let's plot this signal as well as the peaks that were located by findpeaks
:
plot(1:numel(vec), vec, locs, vec(locs), 'r.');
The original data is plotted in blue while the detected peaks are plotted in red. This is what I get:
Good luck!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…