If your dominant peaks are seperated like in the plot you included, there is a parameter for findpeaks()
that can help a whole lot. Try:
findpeaks(x, 'MINPEAKDISTANCE', dist);
with x
being your magnitudes and dist
being a distance you can assume to be te smallest distance between 2 peaks. This might give you a false peek in between 2 peek that are more than 2*dist
from each other, if so consider adding a small threshold with 'MINPEAKHEIGHT'
Another Option is calulating your threshold dynamicly, for exsample by calulating the mean m
and the standard deviation sigma
and setting a threshold by only counting peaks that are n*sigma
above m
.