How to remove high frequncies having fft?

838 Views Asked by At

What are the units of measure of FFT elements?

Can I just set higher elements to zero to filter out higher frequencies? It looks like no.

>> x=0:0.1:10;
>> y=sin(x);
>> f=fft(y);
>> plot(real(f))

gives

enter image description here

which shows, that FFT contains not one peak for clear sinusoid.

If I set to zero upper half of FFT

>> f2=f;
>> f2(1,50:end)=0;
>> y2=ifft(f2);
>> plot(x,y,'-',x,y2,'x')

I get

enter image description here

the same sinusoid with lesser amplitude.

My questions are:

1) what are additional peaks in FFT for pure sinusoid?

2) aren't they relate with moire?

3) how to clear unneeded frequencies from FFT by zeroing elements?

2

There are 2 best solutions below

0
On

Hint 1: By default the fft function in MATLAB starts indexing at 0. In order to get an accurate plot, use the fftshift function.

Hint 2: The deltas of the Fourier transform of a sinusoid come in complex conjugate pairs.

6
On

You don't have an integral number of waves in your function, so there is a jump discontinuity at the end of the interval. This makes lots of high frequency content. Try choosing a wavelength that fits evenly in your interval.
Look at the documentation for how the frequencies are arranged in $f$. In Numerical Recipes there is a good discussion of what they claim is the practical standard-positive frequencies increase from zero to max through the first half of the fft array, then the negative frequencies come from max down to zero. So when you zeroed out the last half of the array you removed all the negative frequencies.