1
votes

I am using fftw for FFTing a signal which has a sampling rate (changes every time I get a new sample) around 10+-0.05Hz. My input signal has 200 samples. I am getting an output of 100 complex nos. Now to get the resolution for my fft and get a frequency corresponding to evry bin I use this:

sampFreq = (float)numFrames*1000000/diffT;
a=sampFreq/numFrames;           //freq resolution of each fft bin
b=a/2;
freq = a*index + b;            // where index is the index of output bin

numFrames is my initial input size to fft (200) and not the output size. Am I doing it correct or missing a factor of 2? Also do I need to use Windowing for this case (as in sampling at ~10Hz and 200 frames)

Also please note I am not zero padding my signal as fftw documentation says the sampels can be a multiple of smaller primes, not necessarily only 2, so 200 works I guess.

2

2 Answers

4
votes

Yes, you need to use a window function prior to the FFT, otherwise you will suffer with spectral leakage (your spectrum will be smeared).

The resolution of your spectrum is just Fs / N = 10 / 200 = 0.05 Hz, so your 100 point spectrum represents frequencies from 0 Hz (DC) to 5.0 Hz (Nyquist) with each "bin" having a width of 0.05 Hz.

Note that the jitter in your sample rate will have a somewhat unpredictable effect on the resulting spectrum - at the very least it will be somewhat inaccurate, and the resolution will probably suffer.

4
votes

Windowing reduces frequency resolution, due to a wider/fatter main lobe, but reduces the effects of interference and noise, due to a much lower stop-band attenuation of each DFT/FFT bin filter. Which effect is worse depends on the signal-to-noise ratio and/or the type of interference in the signal under analysis. A window is more likely to be useful at higher expected noise or interference levels.

Frequency resolution of isolated spectral peaks well above the noise floor can be much finer than 1 DFT/FFT bin width by using a high-quality interpolation kernel. Resolution of separating of two individual peaks, with a minimum 3 dB separation gap, is roughly 2 to 3.5 DFT/FFT bin widths, depending on the windowing used. No window (e.g. a rectangular window) gives the best resolution of resolving 2 closely spaced spectral peaks in zero noise.