Normalization of zero padded signals

조회 수: 11 (최근 30일)
Marc Fuller
Marc Fuller 2022년 10월 21일
편집: Matt J 2022년 10월 24일
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)))
FFT of 4 PT moving average
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개)

Matt J
Matt J 2022년 10월 21일
편집: Matt J 2022년 10월 21일
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 = 0.2500
Xpowrsum=norm(X).^2
Xpowrsum = 0.2500
  댓글 수: 6
Matt J
Matt J 2022년 10월 22일
편집: Matt J 2022년 10월 22일
The definition of the DFS will indeed vary from textbook to textbook. The bottom line is if you want your DC component to be the average of the signal values, you would divide fft() by N. Otherwise, DC will be the sum of the signal values.
Matt J
Matt J 2022년 10월 23일
편집: Matt J 2022년 10월 23일
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
c =
5.0000 + 0.0000i 3.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i 0.0000 + 0.0000i

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


Marc Fuller
Marc Fuller 2022년 10월 23일
So after thinking about this, here is the reason you should not normalize a filter.
Consider y(t)=x(t) convolved with h(t)- where h(t) is some filter such as the moving average filter in this question.
If we want to be consistent, suppose we transform y(t) with normaiization to Y(f) by dividing by the length of the fft, N
Now if we transfrom x(t) convolved with h(t) We have X(f)H(f) by the convolution theorem. We only want to normalize X(f) to have the product identical with Y(f). since Y(f)/N= (X(f)H(f)/N.
  댓글 수: 9
Paul
Paul 2022년 10월 24일
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))
ans =
4.8831 + 0.0000i 0.1012 + 0.2000i -0.0803 + 0.7535i -0.0803 - 0.7535i 0.1012 - 0.2000i
fft(x).*fft(h)
ans =
4.8831 + 0.0000i 0.1012 + 0.2000i -0.0803 + 0.7535i -0.0803 - 0.7535i 0.1012 - 0.2000i
Matt J
Matt J 2022년 10월 24일
편집: Matt J 2022년 10월 24일
It requires no toolboxes and works on arrays of any dimension.

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

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by