Answers for "frequency spectrum signal python"

0

frequency spectrum signal python

#A short example to extract the frequency spectrum of a signal
import numpy as np
import matplotlib.pyplot as plot
samplingFrequency  = 100
t=np.arange(0,5,1/samplingFrequency)
signal=np.sin(2*np.pi*t)
fourierTransform = np.fft.fft(signal)/len(signal)
fourierTransform = fourierTransform[range(int(len(signal)/2))]
tpCount     = len(signal)
values      = np.arange(int(tpCount/2))
timePeriod  = tpCount/samplingFrequency
frequencies = values/timePeriod
plt.plot(frequencies, abs(fourierTransform))
Posted by: Guest on February-05-2021

Python Answers by Framework

Browse Popular Code Answers by Language