# How to get the frequency of a time-domain signal with limited sample length?

Let's say there is a signal who only has one peak in its power spectrum. I would like to know the frequency at which the peak is (the magnitude of power is not important to me). But I only have very limited sampling length, which leads to a poor resolution in the frequency domain. Can I pad the time-domain signal with zeros before taking the FFT, to get an approximation?

For example, a time-domain signal $x(t)=sin(\omega t)$, where $\omega$ is around 5.5 $rad/s$. The total sample time T is 6.28s, (there is no way to increase T) which means the resolution in the frequency domain is $\frac{2\pi}{T}$ $rad/s$ $\approx$ 1 $rad/s$. If I only want to know the frequency of this time-domain signal (the magnitude is not important to me), can I pad it with zeros to get the approximate value?

Then what is the side-effect of doing so?

• I'm not entirely clear with what you're trying to achieve. However it looks like you're up against the Heissenberg priciple. As you have limited sampling length you're bound to have poor resolution in the frequency domain. – skyking May 19 '17 at 13:12
• @skyking sorry for confusion. Let's say a human operator moves a joystick, the position trajectory is mainly sinusoidal. I would like to know the motion frequency of the joystick. But the measurement time is very short, which means poor resolution. Due to this I can't get a good approximation of the true motion frequency. I'm thinking, if padding the measurement with zeros can help? – W.Fu May 19 '17 at 13:22
• It is not clear because you are talking of a finite length discrete signal but then you say $x(t) = \sin(\omega t)$ which is a continuous time signal with infinite length. What is your sampled signal $y(n)$ ? Once you have it, you can use zero-padding (and windowing) to find the frequency of the largest peak in $Y(k)$, but it won't be exactly the frequency of the largest peak of $X(f)$ (mainly because of the Shannon sampling theorem) – reuns May 19 '17 at 15:49
• @user1952009 Sorry for the confusion. As for the example, the sample frequency is much higher than the signal frequency. The observation period is only a few seconds, 6.28s in this case. So the power of the signal would mainly show on 5 and 6 $rad/s$ in the discrete Fourier transform. Because there is only one peak in the power spectrum, would zero-padding the sampled signal achieve interpolation in the frequency domain (since doing so results in a peak between 5 and 6 rad/s) ? Can I use the peak's location revealed by the interpolation as an approximate of the true frequency of the signal? – W.Fu May 21 '17 at 11:06

The processing you are considering consists of three steps:

1. truncate the infinite signal $x(t)=\sin(\omega t),t\in \mathbb{R}$, to its part corresponding to the finite obsrcation interval $[0,T]$.
2. sample the truncated signal with a sampling period $T_s$, resulting in a finite length discrete-time sequence of $N=\lfloor T/T_s \rfloor$ samples.
3. extend the discrete time sequence to $M\geq N$ samples by zero padding and perform an $M$-point FFT to investigate its frequencies.

The limitations of this approach are mainly introduced at step $1$. When you truncate the infinite signal, you are essentially considering a "windowed" version of the original signal, of the form $x(t) w(t)$ where $w(t)=1,t\in [0,T],$ and $w(t)=0, t\notin [0,T]$. The Fourier transform of the windowed signal is the convolution $X(\omega)*W(\omega)$, with $W(\omega)$ a sinc-like function with a main lobe length that is inversely proportional to $T$. You need to have $T$ sufficiently large so that $W(\omega)\approx \delta(\omega)$, otherwise you will experience poor frequency resolution, which cannot be resolved, no matter what (discrete-time) signal processing you perform next on the windowed signal.

Actually, the discrete-time processing can only result in additional distortion. This will be the case when the sampling period $T_s$ is so large that aliasing occurs. However, even when the sampling period is sufficiently small so that the aliasing effect is negligible, using a large size FFT (i.e., $M\gg N$) will only increase the resolution of the sampled windowed signal and not the original signal.

• Thank you! I understand the effects from step 1 and 2, but I have a question regarding the step 3. As the example in the question, the power of the signal would mainly show on 5 and 6 $rad/s$ in the discrete Fourier transform. However the true location of the peak (Dirac impulse) is 5.5 $rad/s$. Considering there is only one peak, so would zero padding before taking FFT just act as interpolation (as doing this results in a peak between 5 and 6 rad/s)? Can I use the peak revealed by the interpolation as an approximate as the true frequency of the signal? What would be the side effect? – W.Fu May 21 '17 at 10:54
• Note that a (zero-padded or not) FFT essentially performs a sampling of the Discrete-Time-Fourier-Transform (DTFT) of the discrete-time signal. Introducing zero padding, i.e., increasing the size $M$ of the FFT, results in a more "dense" sampling of the DTFT. Note that all the frequency information about the discrete-time signal can be obtained by computing directly the DTFT. We typically compute the FFT instead, as it is more efficient. The accuracy of considering the peak of the DTFT as an estimate of the actual frequency is application-dependent, which you should investigate yourself. – Stelios May 21 '17 at 11:13
• @ W.Fu Thinking more about it, the peak of the DTFT will actually correspond to the actual frequency, if the original signal consists of a single frequency, as is the case here. Therefore, for a sufficiently large $M$, the frequency of the FFT peak will be close to that of the DTFT peak, therefore, it will provide a good estimate of the frequency. – Stelios May 21 '17 at 11:22
• Thank you! Can I consider zero padding as two cascaded windowing effects? The sampled signal has $N$ points, and after zero-padding the extended one has $M$ points. Then can I consider the reverse to have a equivalent effect, i.e., the original signal is windowed to have $M$ points and then this $M$-point observation is windowed again to have $N$ non-zero point? Then in the frequency domain this leads to the DTFT to convolve with two different sinc-like functions (one is the result from the first window and the other is from the second). The effect of zero padding is known. But is this right? – W.Fu May 21 '17 at 12:05
• @ W.Fu Once you perform "step 2", you are dealing with a sampled and windowed version of the original signal. You cannot "undo" the windowing operation, whose effects will appear in the DTFT of the signal. The size of the FFT only affects how densely the DTFT is sampled. Nothing more than that – Stelios May 21 '17 at 13:25