|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import matplotlib.pyplot as plt
import numpy as np
import seaborn
Fs =150; # sampling rate采样率
Ts = 1.0/Fs; # sampling interval 采样区间
t = np.arange(0,1,Ts) # time vector,这里Ts也是步长
ff = 25; # frequency of the signal 采样频率
y = np.sin(2*np.pi*ff*t)
n = len(y) # length of the signal 信号长度
k = np.arange(n)
T = n/Fs
frq = k/T # two sides frequency range 两侧频率范围
frq1 = frq[range(int(n/2))] # one side frequency range单侧频率范围
YY = np.fft.fft(y)
Y = np.fft.fft(y)/n # fft computing and normalization 快速傅立叶变换计算与归一化
Y1 = Y[range(int(n/2))]
fig, ax = plt.subplots(4, 1)
ax[0].plot(t,y)
ax[0].set_xlabel('Time')
ax[0].set_ylabel('Amplitude')
ax[1].plot(frq,abs(YY),'r') # plotting the spectrum 绘制光谱
ax[1].set_xlabel('Freq (Hz)')
ax[1].set_ylabel('|Y(freq)|')
ax[2].plot(frq,abs(Y),'G') # plotting the spectrum
ax[2].set_xlabel('Freq (Hz)')
ax[2].set_ylabel('|Y(freq)|')
ax[3].plot(frq1,abs(Y1),'B') # plotting the spectrum
ax[3].set_xlabel('Freq (Hz)')
ax[3].set_ylabel('|Y(freq)|')
plt.show()
哪里有关于红字部分的基础运用和解释啊,求求各位大佬讲一下 顺便可以帮我讲下这个程序运用到的模块函数意思啊 |
|