Anda di halaman 1dari 3

MATLAB EXERCISE DAR_A6 DIGITAL SIGNAL PROCESSING

Prof. Domingo Rodrguez


LOW-PASS FILTER IMPULSE RESPONSE SIGNAL GENERATION
Change N from N=50 to values of N=100, 250, N=500, and N=1000.

MATLAB m-script: lowpass.m


clear
Fs=10000;
Ts=1/Fs;
tinc=Ts;
N=50;
V=N*Ts;
fm=1500;
finc=Fs/N;
t=0:tinc:V-tinc;
f=0:finc:Fs-finc;
%Generate the impulse Response of the low-pass filter.
Wn=(2*fm)/Fs;
h=fir1(N-1,Wn);
%Plot the impulse response h(t).
plot(t,h)
grid
xlabel('Time in Seconds')
ylabel('Magnitude')
title('Impulse Response of Low-pass filter')
pause
%Compute the Fourier transform of the impulse response.
fh=fft(h);
mfh=abs(fh);
%Obtain Magnitude of Spectrum.
plot(f,mfh)
grid
xlabel('Frequency in Hz')
ylabel('Magnitude')
title('Frequency Response H(f) of Low-pass filter')
pause
afh=angle(fh);
%Obtain Argument of Spectrum.
plot(f,afh)
grid
xlabel('Frequency in Hz')
ylabel('Angle, Phase, or Argument')
title('Frequency Response H(f) of Low-pass filter')
pause
%Use of intrinsic function "fftshift" to obtain standard spectrum.
sfh=fftshift(fh);
sf=-Fs/2:finc:Fs/2-finc;
msfh=abs(sfh);
plot(sf,msfh)
grid
xlabel('Frequency in Hz')
ylabel('Magnitude')
title('Standard Plot of Frequency Response H(f) of Low-pass filter')
pause
asfh=angle(sfh);
plot(sf,asfh)
grid
xlabel('Frequency in Hz')

INEL4301 - COMMUNICATIONS THEORY I


Prof. Domingo Rodrguez
MATLAB Example: Impulse and Frequency Responses
ylabel('Angle, Phase, or Argument')
title('Standard Plot of Frequency Response H(f) of Low-pass filter')

INEL4301 - COMMUNICATIONS THEORY I


Prof. Domingo Rodrguez
MATLAB Example: Impulse and Frequency Responses
Impulse Response of Low-pass filter

0.3
0.25
0.2

Magnitude

0.15
0.1
0.05
0
-0.05
-0.1

1.4

0.5

1.5

2
2.5
3
Time in Seconds

3.5

4.5

5
-3

x 10

Standard Plot of Frequency Response H(f) of Low-pass filter

1.2

Magnitude

1
0.8
0.6
0.4
0.2
0
-5000 -4000 -3000 -2000 -1000
0
1000
Frequency in Hz

2000

3000

4000

5000

Anda mungkin juga menyukai