【发布时间】:2020-10-05 16:41:32
【问题描述】:
我将加速度计传感器数据(时间、x 轴、y 轴和 z 轴)保存在 csv 文件中。我正在尝试从每个轴获取 FFT。我的图表如下:
现在,我想从每个 FFT 图中提取主频率并获得其对应的幅度。经过一番研究,我想出了代码:
def Freq(self):
freqs = arange(1, self.N, 1)[:int(self.N/2) - 1]
Amptsx = (2/self.N)* abs( fft(self.fx)[:int(self.N/2)] )[1:]
Amptsy = (2/self.N)* abs( fft(self.fy)[:int(self.N/2)] )[1:]
Amptsz = (2/self.N)* abs( fft(self.fz)[:int(self.N/2)] )[1:]
print 'The highest frequency in the x axis is:', round(np.argmax(Amptsx),6)
print 'The highest frequency in the y axis is:', round(np.argmax(Amptsy),6)
print 'The highest frequency in the z axis is:', round(np.argmax(Amptsz),6)
print 'The highest amplitude in the x axis is:', round(np.max(Amptsx),6)
print 'The highest amplitude in the y axis is:', round(np.max(Amptsy),6)
print 'The highest amplitude in the z axis is:', round(np.max(Amptsz),6)
return freqs, Amptsx, Amptsy, Amptsz
我的幅度结果是准确的,但频率不是。我的结果如下:
The highest frequency in the x axis is: 0.0.
The highest frequency in the y axis is: 1.0.
The highest frequency in the z axis is: 15.0.
The highest amplitude in the x axis is: 0.768894.
The highest amplitude in the y axis is: 0.59046.
The highest amplitude in the z axis is: 0.3679.
我的猜测是我的频率被四舍五入了。我试图修复它但没有成功。有什么建议吗?
【问题讨论】:
-
这可能是一个错误。
[1:]在我看来很可疑。 -
@mkrieger1 你建议做什么?