Professional Documents
Culture Documents
A copy of Program P3_1 to compute and plot the magnitude and phase spectra of a moving average filter of Eq.
y[n] + 0.71y[n-1] – 0.46y[n-2] – 0.62y[n-3] = 0.9x[n] – 0.45x[n-1] + 0.35x[n-2] + 0.002x[n-3] for 0 2 is given
below:
% Program P3_1
% Evaluation of the DTFT
clf;
% Compute the frequency samples of the DTFT
w = -4*pi:8*pi/511:4*pi;
num = [2 1];den = [1 -0.6];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');
Answers:
Q3.1 The plots of the corresponding frequency responses are shown below:
Real part of H(ej )
8
Amplitude 4
0
-4 -3 -2 -1 0 1 2 3 4
/
Imaginary part of H(ej )
4
2
Amplitude
-2
-4
-4 -3 -2 -1 0 1 2 3 4
/
6
Amplitude
0
-4 -3 -2 -1 0 1 2 3 4
/
Phase Spectrum arg[H(ej )]
2
Phase in radians
-1
-2
-4 -3 -2 -1 0 1 2 3 4
/
The types of symmetries exhibited by the magnitude and phase spectra are due to – the value of omega
The type of filter represented by the moving average filter is – low pass filter
Answers:
Q3.2 The plot of the impulse response of the approximation to the ideal lowpass filter obtained using Program P3_2 is
shown below:
N = 13
0.6
0.5
0.4
0.3
Amplitude
0.2
0.1
-0.1
-0.2
0 2 4 6 8 10 12
Time index n
The length of the FIR lowpass filter is - 13
Q3.3 The required modifications to Program P3_2 to compute and plot the impulse response of the FIR lowpass filter of
Project 3.2 with a length of 20 and a cutoff frequency of c = 0.45 are as indicated below:
N = 20
0.7
0.6
0.5
0.4
Amplitude
0.3
0.2
0.1
-0.1
-0.2
0 2 4 6 8 10 12 14 16 18
Time index n
Q3.4 The required modifications to Program P3_2 to compute and plot the impulse response of the FIR lowpass filter of
Project 3.2 with a length of 15 and a cutoff frequency of c = 0.65 are as indicated below:
clf;
fc = 0.65;
n = [-7.5:1:7.5];
y = 2*fc*sinc(2*fc*n);k = n+7.5;
stem(k,y);
title('N = 15');
axis([0 15 -0.5 1.5]);
xlabel('Time index n');
ylabel('Amplitude');
grid;
N = 15
1.5
1
Amplitude
0.5
-0.5
0 5 10 15
Time index n
< Insert program code here. Copy from m-file(s) and paste. >
A plot of the gain response of a length-2 moving average filter obtained using Program P3_3 is shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From the plot it can be seen that the 3-dB cutoff frequency is at –
Q3.6 The required modifications to Program P3_3 to compute and plot the gain response of a cascade of K length-2
moving average filters are given below:
< Insert program code here. Copy from m-file(s) and paste. >
The plot of the gain response for a cascade of 3 sections obtained using the modified program is shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From the plot it can be seen that the 3-dB cutoff frequency of the cascade is at -
< Insert program code here. Copy from m-file(s) and paste. >
The plots of the impulse responses of the four FIR filters generated by running Program P3_4 are given below :
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Filter #1 is of length __________ with a __________ impulse response and is therefore a Type __ linear-
phase FIR filter.
Filter #2 is of length __________ with a __________ impulse response and is therefore a Type __ linear-
phase FIR filter.
Filter #3 is of length __________ with a __________ impulse response and is therefore a Type __ linear-
phase FIR filter.
Filter #4 is of length __________ with a __________ impulse response and is therefore a Type __ linear-
phase FIR filter.
From the zeros of these filters generated by Program P3_4 we observe that:
< Insert program code here. Copy from m-file(s) and paste. >
Plots of the phase response of each of these filters obtained using MATLAB are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we conclude that each of these filters have __________ phase.
< Insert program code here. Copy from m-file(s) and paste. >
Answers:
Q3.9 A plot of the magnitude response of H1(z) obtained using MATLAB is shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From this plot we observe that the magnitude response has a maximum at = with a value =
Q3.10 Using Program P3_5 we tested the stability of H1(z) and arrive at the following stability test parameters {ki}:
Using Program P3_5 we tested the stability of H2(z) and arrive at the following stability test parameters {ki}:
Q3.11 Using Program P3_5 we tested the root locations of D(z) and arrive at the following stability test parameters {ki}:
From these parameters we conclude that all roots of D(z) are ________ the unit circle.
< Insert program code here. Copy from m-file(s) and paste. >
Answers:
Q3.12 The output sequence generated by running the above program for M = 2 with x[n] = s1[n]+s2[n] as the input
is shown below.
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
The component of the input x[n] suppressed by the discrete-time system simulated by this program is -
Q3.13 Program P3_6 is modified to simulate the LTI system y[n] = 0.5(x[n]–x[n–1]) and process the input x[n] =
s1[n]+s2[n] resulting in the output sequence shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
< Insert MATLAB figure(s)s here. Copy from figure window(s)s and paste. >
< Insert program code here. Copy from m-file(s) and paste. >
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
The results of Questions Q3.12 and Q3.13 from the response of this system to the swept-frequency signal can be
explained as follows:
< Insert program code here. Copy from m-file(s) and paste. >
Answers:
Q3.17 The plots generated by running Program P3_7 are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Its period is -
Answers:
Q3.18 The modified Program P3_8 created by adding appropriate comment statements, and adding program statements
for labeling the two axes of each plot being generated by the program is given below:
< Insert program code here. Copy from m-file(s) and paste. >
Q3.19 The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.20 Program P3_8 was run for the following value of the time-shift -
The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.21 Program P3_8 was run for the following values of the time-shift and for the following values of length for the
sequence -
The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.22 The modified Program P3_9 created by adding appropriate comment statements, and adding program statements
for labeling the two axes of each plot being generated by the program is given below:
< Insert program code here. Copy from m-file(s) and paste. >
Q3.23 The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.24 Program P3_9 was run for the following value of the frequency-shift -
The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.25 Program P3_9 was run for the following values of the frequency-shift and for the following values of length for
the sequence -
The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.26 The modified Program P3_10 created by adding appropriate comment statements, and adding program statements
for labeling the two axes of each plot being generated by the program is given below:
< Insert program code here. Copy from m-file(s) and paste. >
Q3.27 The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Q3.28 Program P3_10 was run for the following two different sets of sequences of varying lengths -
The plots generated by running the modified program are given below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Date: Signature: