I have an array (size 128) of data that I am using FFT on. I am trying to find the frequency of the data through the FFT spectrum. The problem is that the formula freq = i * Fs / N
doesn't seem to be working. My data is quite noisy and I don't know if it is because of my noisy data or because I am doing something else wrong. Below is my raw data:
And this is the spectrum that results from the transform:
I am getting two maximum peaks of equal magnitude at index 4 and 128 in the output array. The frequency of the data should be around 1.1333 Hz, but I am getting 5-6 or completely wrong values when I use the formula:
freq = i * Fs / N;
where i
is the array index of the largest magnitude peak, Fs
is the sampling rate in Hz, and N
is the data size.
Using my data, you get freq = (4 * 11.9) / 128
= 0.37 Hz, which is very off from what is expected.
If my calculation is correct, are there any ways to improve my data? Or, are my calculations for frequency incorrect?
i
is the index shown in your Spectrum plot, then the result will be off by a factor of 2 (not helping your case though). Then you have a strong average value/very low frequency component (the section of raw data varies between 98-100, instead of near 0) which would naturally appear in the lower spectrum bins. Remove that bias and you might better see spectrum peaks associated with you data oscillations. – SleuthEye