純粋な正弦関数のスペクトログラム プロットを取得しようとしています。それと一緒に、その信号全体の fft のプロットを表示したいと思います。時間的に静止している同じ信号を扱っていたので、ピークが同じ周波数にあると予想しています。
コード
samplingFrequency = 32.
frequency = 4 #frequency of the sinus wave
t = arange(0,20,1/samplingFrequency) #time intervals with period 1/sampling frequency
y = cos(2*pi*frequency*t)
Y = fft.fft(y) #standard fft on the whole signal
frequencyAxis = fft.fftfreq(len(Y),1/samplingFrequency ) #adjusting the x axis
#PLOTTING
fig, (ax1,ax2) = plt.subplots(nrows=2, ncols=1)
ax1.specgram(y, Fs = samplingFrequency)
ax2.stem(frequencyAxis,Y,linefmt='r--', markerfmt='ro')
プロット
信号全体の fft は予想どおりで、ピークは 4 にあります。ただし、スペクトグラムは 12 に線をプロットしています。エラーの場所についてのアイデアはありますか?
更新 は次のバージョンを使用していました:
- matplotlib '1.1.1'
- numpy '1.6.2'
- パイソン2.7.3