
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++)
{
chart1.Series["Series1"].Points.AddXY
(i,samples[i].Real);
}
Fourier.Forward(samples,FourierOptions.Matlab);
for (int i = 0; i < samples.Length; i++)
{
chart2.Series["Series1"].Points.AddXY
(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.


Coordinator
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 realvalued signals the FT will be realeven and imagniaryodd, so there is a symmetry between positive and negative frequencies. Indeed, you'll be only interested in the positive frequencies at indices 0500, which represent the
frequencies 01 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).

