필터 지우기
필터 지우기

FFT with windowing amplitude correction

조회 수: 71 (최근 30일)
CduP
CduP 2020년 4월 9일
댓글: Elliott Martinson 2021년 5월 17일
I am trying to calculate the FFT of a pressure signal with the correct amplitude, as I want to calculate the resulting sound pressure level from the FFT.
Basically, I can calculate the FFT amplitude correctly when I don't use a window, but I want to use a Hanning window and I do not know how to normalize for the window power. In the code below, from this post https://www.mathworks.com/matlabcentral/answers/33653-psd-estimation-fft-vs-welch, the FFT is normalized by window power by taking FFT/(window'*window). However, the FFT is never normalized by dividing by the length Nx of the signal. But still, the correct PSD is found. From what I can understand, the result from pwelch should also be scaled before it can be used to obtain the correct sound pressure levels.
Fs = 1024;
t = (0:1/Fs:1-1/Fs).';
x = sin(2*pi*t*200);
Nx = length(x);
% Window data
w = hanning(Nx);
xw = x.*w;
% Calculate power
nfft = Nx;
X = fft(xw,nfft);
mx = abs(X).^2;
% Normalize by window power. Multiply by 2 (except DC & Nyquist)
% to calculate one-sided spectrum. Divide by Fs to calculate
% spectral density.
mx = mx/(w'*w);
NumUniquePts = nfft/2+1;
mx = mx(1:NumUniquePts);
mx(2:end-1) = mx(2:end-1)*2;
Pxx1 = mx/Fs;
Fx1 = (0:NumUniquePts-1)*Fs/nfft;
[Pxx2,Fx2] = pwelch(x,w,0,nfft,Fs);
plot(Fx1,10*log10(Pxx1),Fx2,10*log10(Pxx2),'r:');
legend('PSD via FFT','PSD via pwelch')
If someone can please clarify exactly how to calculate a windowed FFT of which the amplitude is correctly scaled for signal length and window power, it would be greatly appreciated. Matlab's documentation is not very clear on the subject.
  댓글 수: 1
Elliott Martinson
Elliott Martinson 2021년 5월 17일
you're normalizing after squaring.
should normalize BEFORE you square the fft results. Otherwise you could (i suppose) square the normalization factors as well, but that seems silly

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by