Plot the frequency spectrum
数学形式
FFT 求频谱相关
FFT 就是快速 DFT。你的数据采样间隔
做 FFT 并绘制,你将得到最大频率
N = len(x) # Number of samples
T = 1.0 / 200.0 # Sampling interval (1/200 Hz)
yf = np.fft.fft(x) # Compute the FFT 频率分量
xf = np.fft.fftfreq(N, T)[:N // 2] # 获取实际频率作为横轴
# Plot the frequency spectrum
plt.plot(xf, 2.0 / N * np.abs(yf[:N // 2])) # Normalize and plot
ref: https://zhuanlan.zhihu.com/p/620462217 含有 FFT 算法证明
verified using sin wave (generate + fft) on 24.8.21