# Length of DFT defines whether I see the harmonic or the dominant frequency

I have a number of signals that are periodic. I use an fft transformation to obtain the dominant frequency of each signal. In order to increase the frequency resolution I zero pad the signal before the fft. However I noticed that when the frequency is low, the peak of the fft corresponds to the first harmonic. A sample of my signal looks like this: My code is the following:

N = 4000; %signal length
minf= 0.5; % Hz
maxf= 20; %Hz
resf = 0.01; % Hz resolution
fs = 2000; % Hz sampling frequency

NFFT = fs/resf;
Freq = fft(mysignal,NFFT);
Freq = Freq((minf/resf)+1:(maxf/resf)+1,:);


In this case the fft will perform well and detect the 1.12Hz frequency. However I noticed that when my signal's frequency is below 1Hz, as dominant frequency I will get the 1st Harmonic as the pick of the fourier domain plot and not the dominant frequency. In that case I can change the line  NFFT = fs/reso_freq; to NFFT = fs/reso_freq/2; which will actually give me the correct frequency, but it will not work for when my signal is above 1Hz. Can someone explain to me why this is the case and if there is a universal way of finding the correct frequency without knowing what to expect beforehand.

Thank you

## 2 Answers

Zero padding does not increase the frequency resolution— it just interpolates more samples in frequency but does not give you any more information. The frequency resolution in Hz of an non-windowed (rectangular window) Fourier Transform is 1/T where T is the length of your time domain waveform in seconds. You must have a longer data sample in order to get higher resolution or see lower and lower frequencies. An extreme case is that you need an infinite amount of time in order to observe a true DC signal.

Note that zero padding gives you more samples of the Discrete Time Fourier Transform (The DTFT is the result if the time axis was allowed to go from minus infinity to plus infinity; by zero padding you approximate that). The Discrete Fourier Transform in contrast has a time axis this only goes from 0 to N-1.

To increase the frequency resolution of your signal, if it can be done by increasing the sampling rate at measurement, this would be the ideal way to improve frequency resolution.