This project has moved and is read-only. For the latest updates, please go here.

Numerics FFT result interpretation

Apr 18, 2015 at 10:22 PM
I am new to Math .net numerics and still trying to understand the FFT library. Based on the some examples, I've written following code:
            Complex[] samples = new Complex[1000];
            double[] s =  Generate.Sinusoidal(1000, 2000.0, 200.0, 10.0);
            for (int i = 0; i < 1000; i++)
                samples[i] = new Complex (s[i],0);

            for (int i = 0; i < samples.Length; i++)


            for (int i = 0; i < samples.Length; i++)
                        (i, samples[i].Real);


based on my understanding of FFT, i should get impulse at 200Hz and frequency resolution should be fs/N.
But the peak is coming at 900th sample, which i'm not sure pointing to 200Hz. If my interpretation is correct?
Any help would be appreciated. Thanks in advance.
Apr 19, 2015 at 7:20 AM
You actually have two peaks of the same magnitude, one at index 100 and one at index 900, hence 200 Hz (100 * 2 Hz).

This is expected since for real-valued signals the FT will be real-even and imagniary-odd, so there is a symmetry between positive and negative frequencies. Indeed, you'll be only interested in the positive frequencies at indices 0-500, which represent the frequencies 0-1 kHz in steps of 2 Hz (fs/N) - which is all you can represent with a 2 kHz sampling rate.

Be aware that you need to look at the magnitude of the frequency space values, not only their real value. In fact your input sample signal is odd, so the frequency space is imaginary only (the real values are all zero).