Python Forum

Full Version: Harmonics and their Magnitude values
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I am new to python, my problem is to find the harmonics values of the given signal after applying FFT(Fast fourier Transform) and their corresponding amplitude values.
I am able to find fundamental frequency and its magnitude value, but am not able to find next harmonics values and their magnitude values.
Let's Think F is the Fundamental Frequency , 2F, 3F, 4F are their harmonics values but am not getting logic behind to find their corresponding magnitude values in python and how to display harmonics values on the graph.


Thanks in advance.
Hello and welcome to the forum.
We are always glad to help and guide you in the righty direction, but we need to see what have you tried. Please, post your code in python tags, full traceback in error tags (if you get any errors) and ask specific questions.
See BBcode help for more info.
Please, also mread What to include in a post
This is the code for FFT of a give signal x, the fundamental frequency is getting correct but am not able to find next harmonics values and their corresponding amplitude values.


nfft = len(x)
nfft2 = 2**nextpow2(nfft)
ff = fft(x, nfft2)
fff = (ff[: nfft2/2])
#xfft = np.ndarray Fs*[: (nfft2/2-1)/nfft2]
xf = np.linspace(0.0, 1.0/(2.0*T), nfft2/2)
plt.plot(xf, abs(fff))
plt.show()
idx = np.argmax(np.abs(fff))
print('Fundamental frequency :',  xf[idx])
Thanks for the reply..
I want to find next 6 harmonics values and their corresponding magnitude values..
The link which was given , I referred previously but i didn't get..

Thanks in advance.