Categories
MATLAB

Discrete Fourier Transform (DFT) of a sinusoid signal with a non-integer frequency value / Zero padding + Windowing

Any time a DFT analyses sinusoids of exactly an integer number of cycles we only have spectral energy at one location or one bin value as seen in the article “DFT of sinusoid signal with an integer frequency value”. In this example we are analysing a sinusoid that does not have an integer number of cycles. We have here many non zero values and not the situation where there was only 1 DFT bin been excited. We get a spread of spectral energy across a number of bins. The shape of the Magnitude spectrum here is quite different from the shape of the magnitude spectrum seen before and also the amplitude of the highest point is much lower.

For a fractional number of frequency (eg f1=2.5Hz) most energy is accumulated around bins 2 & 3. There is a smearing ‘leakage’ effect present here and it arises because we are effectively calculating the fourier series for the waveform which has major discontinuities, hence other frequency components present.

The solution to reduce the leakage, is to use a window function (eg hamming / hanning / kaiser or any other windowing techniques) to taper the samples towards zero values at both endpoints so there is no discontinuity (or very little in the case of hanning window).

The hanning window touches zero at both ends eliminating all discontinuity. Hamming window doesn’t quite reach zero and thus still has slight discontinuity in the signal. Because of this difference the hamming window does a better job of cancelling the nearest sidelobe but a poorer job of cancelling any others. Kaiser window can be used with different beta values. As beta increases, the relative sidelobe attenuation decreases and the main lope width increases.

Without windowing sidelobes are present apart from the main lobe. Sidelobes are very problematic and cause interference with some of the measurements in the frequency domain. So these have to be reduced or eliminated.

Zero padding the signal in the time domain will also be required. It enables us to obtain more accurate amplitude estimates of resolvable signal components. If we also use a windowing function, recommendation is to window the signal first before we zero-pad it.

The minimum number of zeros in this example that we can add to the signal is 100. The time domain creates a new signal of 200 samples, 100 first samples of sinusoidal signal 2.5 cycles & the rest was padded with 100 zeros. It simply adds zeros to the end of the time domain signal to increase it’s length. Zero padding only changes the density of the samples. There are now 200 frequency bins in the frequency domain compared to 100 before.

Here is the MATLAB code that illustrates the issues seen in the frequency domain on a sinusoidal signal with a fractional frequency number and how these were resolved :

https://usercontent.one/wp/www.kevnugent.com/wp-content/uploads/2020/10/fft_plot_1.pdf?media=1712708755