📜  频谱信号python代码示例

📅  最后修改于: 2022-03-11 14:46:25.083000             🧑  作者: Mango

代码示例1
#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))