Applying low pass filter in frequency domain

171 次查看(过去 30 天)
Hi.
I have a signal x(t) with white noise.
Then I have to apply low pass filter in frequency domain and observe the result in time domain.
So I coded this way.
  1. Calculate X = Fourier transform of x(t)
  2. Let low pass filter(H) be rectangularPulse with cut-off frequency
  3. Apply the low pass filter to X -> Y=HX in frequency domain.
  4. To observe the result in time domain, applying ifft(Y)
I attach code below.
fs=4; %sampling frequency
t=0:1/fs:256; % time domain
f=linspace(-pi,pi,length(t)); % frequency domain
N=0+0.2*rand(length(t),1); %white noise
x=2*cos(2*pi/12*t).*exp(-((t-90).^2)/35/35) + 1.5*cos(2*pi/6*t+pi/6).*exp(-((t-130).^2)/35/35)+1*cos(2*pi/4*t+pi/3).*exp(-((t-170).^2)/35/35)+N.'; %signal
X=fftshift(fft(x))/length(t); %Fourier transform of the signal
H=rectangularPulse(-0.13,0.13,f); %low pass filter with cut off frequency=0.13
Y=X.*H; %apply low pass filter to X in frequency domain
a=ifftshift(ifft(Y)); %inverse Fourier transform of Y to observe the result in time domain
My question is
  1. Is my approch correct?
  2. I confused about the scale factor. If I apply ifft, what is the scale factor? For example, in fft case, we have to divide fft withe the number of points to gain 'amplitude'.
  3. I know the difference between fft and ifft in theory, but in matlab, what is difference between fft and ifft? Because of duality of Fourer transform, I think the resualt fft and ifft is the same.
  4. By convolution theory, ifft(Y) is the same with conv(ifft(H),x), but it is not. Why??
Thank you for reading my questions.

采纳的回答

Star Strider
Star Strider 2020-8-24
Some of it appears to be correct.
To see the result, add this to your code:
figure
plot(f,abs(X), f,abs(Y))
grid
legend('Original','Filtered')
However the ‘a’ calculation does not appear to be correct. Take a closer look at the order of the function calls, and remember to re-scale it by multiplying it by the number of elements in the ‘t’ vector, since you correctly scaled the original fft by dividing it by that value.
Use this to see the result:
figure
plot(t,x, t,a)
grid
legend('Original','Filtered')
Since this appears to be homework, we give only hints, not code.
.
  5 个评论
Star Strider
Star Strider 2021-10-22
1) I am struggling to understand why the fft must be divided by the length of the time array:
That normalises the amplitudes.
How do I determine the limits of the frequency domain?
For a one-sided Fourier transform, 0 to the Nyquist frequency, for a two-sided Fourier transform from -Nyquist frequency to +Nyquist frequency. The Nyquist frequency corresponds to π in normalised frequency units of rad/time unit or rad/spatial unit, or whatever the original signal is with respect to.
.
Michael
Michael 2022-10-28
If you start with N points and a sampling frequency of 2 * Nyquist
then deltaF = 2 * Nyquist / N
and the two sided frequency range goes from -Nyquist to +(Nyquist - deltaF)
so you have N/ 2 negative frequencies and N/2 positive frequencies starting at 0
if you go -Nyquist to + Nyquist then you have N + 1 points

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by