FFT and accelerometer data: why am I getting this output?

给你一囗甜甜゛ 提交于 2019-12-04 02:27:31

问题


I have read various posts here at StackOverflow regarding the execution of FFT on accelerometer data, but none of them helped me understand my problem.

I am executing this FFT implementation on my accelerometer data array in the following way:

int length = data.size();
double[] re = new double[256];
double[] im = new double[256];
for (int i = 0; i < length; i++) {
    input[i] = data[i];
}

FFT fft = new FFT(256);
fft.fft(re, im);

float outputData[] = new float[256];
for (int i = 0; i < 128; i++) {
    outputData[i] = (float) Math.sqrt(re[i] * re[i]
    + im[i] * im[i]);
}

I plotted the contents of outputData (left,) and also used R to perform the FFT on my data (right.)

What am I doing wrong here? I am using the same code for executing the FFT that I see in other places.

EDIT: Following the advice of @PaulR to apply a windowing function, and the link provided by @BjornRoche (http://baumdevblog.blogspot.com.br/2010/11/butterworth-lowpass-filter-coefficients.html), I was able to solve my problem. The solution is pretty much what is described in that link. This is my graph now: http://imgur.com/wGs43


回答1:


The low frequency artefacts are probably due to a lack of windowing. Try applying a window function.

The overall shift is probably due to different scaling factors in the two different FFT implementations - my guess is that you are seeing a shift of 24 dB which corresponds to a difference in scaling by a factor of 256.




回答2:


Because all your data on left are above 0, for frequency analyze it is a DC signal. So after your fft, it abstract the DC signal out, it is very hugh. For your scene, you only need to cut off the DC signal, just preserve the signal over 0 Hz(AC signal), that makes sense.



来源:https://stackoverflow.com/questions/12007071/fft-and-accelerometer-data-why-am-i-getting-this-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!