这是在正弦信号上使用DST-II的简单代码 如何在水平轴上以Hz为单位绘制正确的频率值? 感谢您的帮助。
from scipy.fft import fftfreq,dct,dst,idct,idst
import matplotlib.pyplot as plt
tmin=0.
tmax=5.
Ns = 16384
fs = (tmax-tmin)/Ns
ts = np.linspace(tmin,tmax,Ns,endpoint=False)
f=10
xs=np.sin(2.*np.pi*f * ts)
hatx = dst(xts,type=2,norm='ortho')
plt.plot(np.abs(hatx)**2,label="sans bruit",c='b',lw=0.5)
plt.xscale('log')
plt.yscale('log')