Saturday 26 September 2015

fft - Why do we say that "zero-padding doesn't really increase frequency resolution"


Here is a sinusoid of frequency f = 236.4 Hz (it is 10 milliseconds long; it has N=441 points at sampling rate fs=44100Hz) and its DFT, without zero-padding :


enter image description here



The only conclusion we can give by looking at the DFT is: "The frequency is approximatively 200Hz".


Here is the signal and its DFT, with a large zero-padding :


enter image description here


Now we can give a much more precise conclusion : "By looking carefully at the maximum of the spectrum, I can estimate the frequency 236Hz" (I zoomed and found the maximum is near 236).


My question is : why do we say that "zero-padding doesn't increase resolution" ? (I have seen this sentence very often, then they say "it only adds interpolation")


=> With my example, zero-padding helped me to find the right frequency with a more precise resolution !



Answer



Resolution has a very specific definition in this context. It refers to your ability to resolve two separate tones at nearby frequencies. You have increased the sample rate of your spectrum estimate, but you haven't gained any ability to discriminate between two tones that might be at, for instance, 236 Hz and 237 Hz. Instead, they will "melt together" into a single blob, no matter how much zero-padding you apply.


The solution to increasing resolution is to observe the signal for a longer time period, then use a larger DFT. This will result in main lobes whose width are inversely proportional to the DFT size, so if you observe for long enough, you can actually resolve the frequencies of multiple tones that are nearby one another.


--



To see how this plays out, here's a plot of the zoomed-in FFT of the addition of two signals: your original sinusoid, and one that differs in frequency from it by 0 to 100 Hz.


It's only towards the 100Hz difference end of the plot (left-hand side here) that you can distinguish (resolve) the two.


Scilab code for generating the plot below.


enter image description here


f = 236.4;
d = 10;
N=441;
fs=44100;
extra_padding = 10000;


t=[0:1/fs:(d/1000-1/fs)]
ff = [0:(N+extra_padding-1)]*fs/(N+extra_padding);

x = sin(2*%pi*f*t);

XX = [];

for delta_f = [0:100];
y = sin(2*%pi*(f+delta_f)*t);
FFTX = abs(fft([x+y zeros(1,extra_padding)]));

XX = [XX; FFTX];
end

mtlb_axis([0 1300 0 500])

figure(1);
clf
[XXX,YYY] = meshgrid(ff,0:100);
mesh(XXX(1:100,[50:90]),YYY(1:100,[50:90]),XX(1:100,[50:90]))

No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...