3
$\begingroup$

I have a set of 512 samples that I have collected with a sensor. I'd like to apply zero padding to it, for better frequency bin resolution. However, all the tutorials I see to make this occur center around the idea that your wave is localized around zero. Here is an example:

enter image description here

Adding 10,000 zeros to the end of this signal seems logical to me.

However, say that the Y values on the above graph are shifted 5,000 points.

In that case, would you still add 10,000 zeros to the end of the singal?

Or, would you average out your signal ( find the median ), and use that as the padding? Given that the Y coordinates shifted 5,000 points, then we might be adding 10,000 pads of 5,005.

$\endgroup$

2 Answers 2

5
$\begingroup$

I'd like to apply zero padding to it, for better frequency bin resolution.

First of all, let's state it one more time that zero padding does not improve frequency resolution of DFT. It'll only interpolate the existing spectrum on a finer frequency grid, but will not add any new information to it, otherwise.

In order to improve the true frequency resolution of a DFT computation, you have to take more samples and therefore increase the length of the signal.

Zero padding is applied by adding zeros to the end of the signal to make it length N, where you then compute $N$-point DFT of it afterwards.

Lets consider the following concrete example of the sum of two sinusoidals: $$x[n] = 0.73 \cos(0.25\pi n +\pi/12) + 0.87 \cos(0.28 \pi n + \pi/17)$$

And we shall represent $x[n]$ by a finite length $L$ segment and take $N$-point DFT of it to see a spectral vision of it.

In the first case, let signal length $L=16$ and let DFT-length be $N = 64$. The following is the resulting DFT magnitude plot: enter image description here

Now, apply zero padding to $x[n]$ and make it length $N=1024$ samples (by adding zeros) and take 1024-point DFT over the still $L=16$ length signal, with the result: enter image description here

As you can see although increasing DFT length (equivalently zero padding) increases the smoothness of the spectrum, it does not resolve the two sinusoidals embedded in $x[n]$ at the window length of $L=16$.

Now lets increase the signal sample count by setting $L=512$ (taking more samples of $x[n]$ instead of adding zeros to it) and again taking $N=1024$ point DFT of the segment, whose result is: enter image description here

As can be seen, now the two sinusoidals are finely resolved while still computing the same $N=1024$ point DFT but over a longer signal observation length ($L=512$), hence, demonstrating the fact that the spectral resolution is improved by longer signal observation and not by longer DFT (by zero padding).

$\endgroup$
1
1
$\begingroup$

Are you sure you want to take the DFT of the PHASE of a signal?

That doesn't make sense to me, since phase is a cyclic variable, which has discontinuities at branch cuts (+-180º) when turning around a complete loop.

I suggest converting the list of phase samples into a list of complex-valued samples, using the formula new[j] = Exp (i * old[j] * Pi / 180) for each j of the list, and taking the DFT of the new list

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.