fft:为什么我的主峰比副峰低? [英] fft: why my main peak is lower than the side peak?

查看:176
本文介绍了fft:为什么我的主峰比副峰低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始数据位于 Google驱动器上.它是两列数据,t和x.我做了下面的离散fft变换. 我不太明白主峰(尖峰)的高度比侧峰低.第二个子图显示确实是尖峰(最接近2.0)是主频率.代码和图形如下:

The original data is on the google drive. It is a two columns data, t and x. I did the following discrete fft transform. I don't quite understand that the main peak(sharp one) has a lower height than the side one. The second the subplot shows that it is indeed that the sharp peak(most close to 2.0) is the main frequency. The code and the figure is as follows:

import numpy as np
import math
import matplotlib.pyplot as plt
from scipy.fftpack import fft,fftfreq

freqUnit=0.012/(2*np.pi)
data = np.loadtxt(fname='data.txt')
t = data[:,0]
x = data[:,1]
n=len(t)
d=t[1]-t[0]

fig=plt.figure()
ax1=fig.add_subplot(3,1,1)
ax2=fig.add_subplot(3,1,2)
ax3=fig.add_subplot(3,1,3)

y = abs(fft(x))
freqs = fftfreq(n, d)/freqUnit

ax1.plot(t, x)
ax2.plot(t, x)
ax2.set_xlim(40000,60000)
ax2.set_ylim(0.995,1.005)
ax3.plot(freqs,y,'-.')
ax3.set_xlim(0,4)
ax3.set_ylim(0,1000)
plt.show()

推荐答案

您需要应用窗口函数在FFT之前,否则您将看到上述伪像,尤其是在频谱中的峰值与FFT bin中心不直接对应的情况下.

You need to apply a window function prior to your FFT, otherwise you will see artefacts such as the above, particularly where a peak in the spectrum does not correspond directly with an FFT bin centre.

请参阅问题以获取更多详细信息.

See "Why do I need to apply a window function to samples when building a power spectrum of an audio signal?" question for further details.

这篇关于fft:为什么我的主峰比副峰低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆