I am trying to replicate the MATLAB function findpeaks()
in Python using find_peaks()
from scipy.signal
.
Basically I'm trying to translate the MATLAB example
I can't figure out why find_peaks()
is working fine the 1st time (when all peaks are determined) but fails to give the correct results the 2nd time when more arguments are provided to find the highest peaks.
How can I detect the highest peaks of the 2nd period correctly?
CodePudding user response:
I'm answering my own question.
I realized that the only mistake I was doing in my Python code was not normalizing the autocorr values as was done in the Matlab example. I simply added the following in my code:
autocorr = (autocorr-min(autocorr))/(max(autocorr)-min(autocorr))
When I do so, I eventually get the desired results, same as that in the example:
Hence, to conclude, find_peaks() does in fact do the intended job.