Normalization of zero padded signals
이전 댓글 표시
I have a simple question regarding zero padding and normalization. Consider an impulse resonse of a 4 point moving average filter. and its fft zero padded to 1024 points..
x=[1/4 1/4 1/4 1/4]
X=fft(x,1024 )
xpowrsum=dot(x,x)
Xpowrsum=dot(abs(X),abs(X))/1024
plot(fftshift(abs(X)))

By Parsevals theorem the two energies are equal as expected. However, the fft without scaling shows the correct frequency response with a gain of 1 at 0 Hz. So why do I always read the FFT should be scaled by the number of samples before zero padding (in this case 4) if I am interested in the magnitude response of the filter?
답변 (2개)
So why do I always read the FFT should be scaled by the number of samples before zero padding (in this case 4) if I am interested in the magnitude response of the filter?
The FFT is a tool with many applications, each with its own appropriate scaling.
Scaling by 1/N is done when the FFT is being used to evaluate the Discrete Fourier Series.
When it is being used to approximate the continuous Fourier transform, it is scaled by the time sampling interval 1/Fs.
To achieve Parseval's equality, the fft should be scaled by 1/sqrt(N):
x=[1/4 1/4 1/4 1/4];
X=fft(x,1024 )/sqrt(1024);
xpowrsum=norm(x).^2
Xpowrsum=norm(X).^2
댓글 수: 6
Marc Fuller
2022년 10월 21일
Yes, it is equivalent, but you asked "why do I always read the FFT should be scaled by the number of samples ..." and I've explained to you that it shouldn't, unless you are trying to compute the Discrete Fourier Series. In a Discrete Fourier Series, the DC harmonic is the mean of the signal values, not the sum of the signal values.
If you think your DC value should be 1, for whatever it is that you're doing, then you are correctly scaling the FFT for whatever it is that you're doing.
Paul
2022년 10월 22일
Is it standard practice to include the 1/N factor in the definition of the DFS coefficients? I feel like I've also seen it the other way, i.e., the DFS coefficients don't include the 1/N, as is the case in fft, and the 1/N is then applied to the sum that reconsructs the signal from those DFS coefficients.
Marc Fuller
2022년 10월 22일
One example to motivate the 1/N factor is to consider a periodic signal like,
If the goal is to recover the coefficients of the sinusoidal terms (5 and 3), we can see in the following code that the 1/N is necessary.
N=10;
n=(0:9)';
x=5+3*exp(1j*2*pi*n/N);
c=fft(x)/N
Marc Fuller
2022년 10월 23일
0 개 추천
댓글 수: 9
Marc Fuller
2022년 10월 23일
Matt J
2022년 10월 23일
I'm not suggesting here that you transform the filter. I'm suggestign that the convolution theorem include an additional scale factor of N. Errata: above I should instead have had,
FFT(conv(x,h))=N( FFT(x).*FFT(h))
Now you are free to normalize all the FFTs by 1/N and th equation will still be true.
Paul
2022년 10월 23일
The governing equation for the linear system is
DTFT(h[n]*x[n]) = H(f)X(f) where H(f) = DTFT(h[n]) and X(f) = DTFT(x[n]).
To approximate the RHS of this equation for finite duration sequences h and x using the DFT as implemented by fft, we'd have
H(f)X(f) evaluated at samples of f is the product DFT(h[n],N) .* DFT(x[n],N) where N >> max(numel(x),numel(h)).
If the DFT were implemented with the 1/N factor, we'd have to multiply the DFT product by N^2 to recover the correct magnitude of the DTFT.
The FFT as currently implemented in Matlab satisfies,
FFT(conv(x,h))= FFT(x).*FFT(h)
If we divide by N^2 on both sides this becomes,
FFT(conv(x,h)/N)/N= FFT(x)/N.*FFT(h)/N
which means the equation is still true if the FFT() operator is replaced by FFT()/N and the conv() operator is replaced by conv()/N.
Kind of getting off the topic of normalization, but I don't think this equation can be true
FFT(conv(x,h))= FFT(x).*FFT(h)
numel(conv(x,h)) = numel(x) + numel(h) - 1
but the numel of the RHS is equal to numel(x) (and numel(h) since numel(x) == numel(h) for the .* to work).
Illustrating my comment above with some data.
rng(100);
h = rand(1,10); % FIR
x = rand(1,15); % input
z = conv(h,x); % output
[Z,w] = freqz(z,1,linspace(0,2*pi,1024)); % DTFT of output
H = fft(h,128); % zero-padded DFT of impulse response
X = fft(x,128); % zero-padded DFT of input
ww = (0:127)/128*2*pi;
figure % plot gain and phase.
hold on
stem(ww,abs(H.*X))
plot(w,abs(Z))
figure
hold on
stem(ww,angle(H.*X))
plot(w,angle(Z))
Kind of getting off the topic of normalization, but I don't think this equation can be true FFT(conv(x,h))= FFT(x).*FFT(h)
Here, I was somewhat abusing the notation "conv()" which is meant to mean cyclic convolution. I demonstrate the equivalence below using my own cyclic convolution routine which I've attached.
x=rand(1,5); h=rand(1,5);
fft(cyconv(x,h))
fft(x).*fft(h)
I thought that you probably meant that. I haven't looked at cyconv. Is it preferred over Matlab's cconv for some reason?
rng(100);
x=rand(1,5); h=rand(1,5);
fft(cconv(x,h,5))
fft(x).*fft(h)
카테고리
도움말 센터 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

