frequency spectrum signal python

Solutions on MaxInterview for frequency spectrum signal python by the best coders in the world

showing results for - "frequency spectrum signal python"
Joshua
16 Mar 2017
1#A short example to extract the frequency spectrum of a signal
2import numpy as np
3import matplotlib.pyplot as plot
4samplingFrequency  = 100
5t=np.arange(0,5,1/samplingFrequency)
6signal=np.sin(2*np.pi*t)
7fourierTransform = np.fft.fft(signal)/len(signal)
8fourierTransform = fourierTransform[range(int(len(signal)/2))]
9tpCount     = len(signal)
10values      = np.arange(int(tpCount/2))
11timePeriod  = tpCount/samplingFrequency
12frequencies = values/timePeriod
13plt.plot(frequencies, abs(fourierTransform))