Pregunta

I am currently in need for filtering accelerometer data for an Android application. First of all, I used a simple low-pass filter (simple infinite impulse response filter) as follows:

for i from 1 to n
   y[i] := y[i-1] + α * (x[i] - y[i-1])

This helped me achieve a smoother result.

Then I decided to play with FFTs. I used a fast-fourier transform to get the signal into frequency domain and then zeroed some of the high frequencies. Then using inverse fourier transform I recreated the signal. This all worked fine and I know that the FFT and IFT implementations are fine. However, the signal wasn't as smooth as the one that I got from before using the simple infinite impulse response filter. I tried zeroing some further frequencies but didn't give me as good of a result as expected.

What is the reason behind this? I though using FFTs and IFT should technically give me a nice smooth graphs. Is this because of the sampling in FFT?

Thanks

¿Fue útil?

Solución

The problem is that you zeroed out the specter, it cannot be zeroed out completely it needs to be a smooth curve in the frequency specter in order for it to hold in the time domain. You will probably hear some kind of feedback on top of your sound and that is the time domain not cooping with the sudden stop in the frequency. Mathematically you can see it in the fft i took of the value 1 here in wolfram. 1 is an infinite long function in the time domain and it is always 1. The fft of 1 is a dirac delta function sqrt(2*pi) and that is the same as an infinite stop in the frequency band. As you see the time domain is infinite long when the frequency is infinite short. And that is why you cannot go to a complete stop in the filter you have created.

I suggest you read up on digital filter design if you want more theory. A fast fix is to accept some db ouput on the frequency you are trying to eliminate. Something like the picture here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top