qslazio
Full Member level 3
fft precision
Hi everybody,
I've met a weird problem really makes me desperate.
The problem is as below,
As we know, hann window's spectrum is defined as[1]:
W(phi)=0.5*D(phi)+0.25(D(phi-2*pi/N)+D(phi+2*pi/N))
where, D(phi)=exp(j*phi)*sin(N/2*phi)/sin(1/2*phi) is the Dirichlet kernel, and N is number of DFT points
the amplitude of spectrum at the first fft bin (phi=0) should be N/2
the amplitude of spectrum at the second and last fft bin (phi=1*2pi/N and phi=(N-1)/N*2pi) should be N/4
the amplitude of spectrum at the rest of fft bins should be 0
hence, in theory, there should be 3 non-zero bins on the spectrum of hann window.
But when I do this in Matlab, I found that the rest of fft bins' amplitude is not so small that it cannot be simply neglected.
As can be seen from the picture in the attachment
for N=1024, the first and second bin's amplitude is 0dB and -6dB as expected, but the rest bins' amplitude are not
zero as theory says (they are around -70dB~-80dB).
The consequence of this problem is that when I do fft with any sine wave plus noise of which the noise floor is below these non-signal bins' amplitude (for example the noise floor is around -100dB), Matlab simply gives me the wrong SNR!!
I can not find any answers or related information from any textbook. I guess it is caused by Matlab fft's internal precision.
Anyone has idea about this?
Thanks a lot!
[1] "On the use of windows for harmonic analysis with the discrete fourier transform", F. J. Harris, Proceedings of the IEEE VOL.66 NO.1, Jan. 1978
the matlab script I used (I'm using Matlab R2006b):
close all;
nbpts=1024;
w=hann(nbpts); % generates hanning window vectors
W=fft(w)/sum(w); % generates normalized fft spectrum
WM=abs(W); % gets amplitude spectrum
figure(1);
plot([1:nbpts],20*log10(WM),'bo-');
xlabel('fft bin');
ylabel('dB');
title('Hann window DFT with N=1024 normalized spectrum');
grid on;
Hi everybody,
I've met a weird problem really makes me desperate.
The problem is as below,
As we know, hann window's spectrum is defined as[1]:
W(phi)=0.5*D(phi)+0.25(D(phi-2*pi/N)+D(phi+2*pi/N))
where, D(phi)=exp(j*phi)*sin(N/2*phi)/sin(1/2*phi) is the Dirichlet kernel, and N is number of DFT points
the amplitude of spectrum at the first fft bin (phi=0) should be N/2
the amplitude of spectrum at the second and last fft bin (phi=1*2pi/N and phi=(N-1)/N*2pi) should be N/4
the amplitude of spectrum at the rest of fft bins should be 0
hence, in theory, there should be 3 non-zero bins on the spectrum of hann window.
But when I do this in Matlab, I found that the rest of fft bins' amplitude is not so small that it cannot be simply neglected.
As can be seen from the picture in the attachment
for N=1024, the first and second bin's amplitude is 0dB and -6dB as expected, but the rest bins' amplitude are not
zero as theory says (they are around -70dB~-80dB).
The consequence of this problem is that when I do fft with any sine wave plus noise of which the noise floor is below these non-signal bins' amplitude (for example the noise floor is around -100dB), Matlab simply gives me the wrong SNR!!
I can not find any answers or related information from any textbook. I guess it is caused by Matlab fft's internal precision.
Anyone has idea about this?
Thanks a lot!
[1] "On the use of windows for harmonic analysis with the discrete fourier transform", F. J. Harris, Proceedings of the IEEE VOL.66 NO.1, Jan. 1978
the matlab script I used (I'm using Matlab R2006b):
close all;
nbpts=1024;
w=hann(nbpts); % generates hanning window vectors
W=fft(w)/sum(w); % generates normalized fft spectrum
WM=abs(W); % gets amplitude spectrum
figure(1);
plot([1:nbpts],20*log10(WM),'bo-');
xlabel('fft bin');
ylabel('dB');
title('Hann window DFT with N=1024 normalized spectrum');
grid on;