514 Practical MATLAB® Applications for Engineers
Example 5.3
Let the real sequence h(n) be given by its DTFT as follows:
He
jW ee e ejW jW jW jW
()
.. ....
0 007 0 034 0 04^234 0 04 0 03 0 009ee
eeee
jW
jW j W j W j W
5
1 2 63.. ..2 81 23 41 5 0 4
Create the script fi le DTFT_H that returns the magnitude and phase plots of the DTFT
of H(ejW) versus W, using 128 discrete points over the range 0 ≤ W ≤ 4 π.
MATLAB Solution
% Script file: DTFT _ H
P = [0.007 0.034 0.04 0.04 0.03 0.009];
Q = [1 2.63 2.81 1.5 0.4];
W = linspace(0,4*pi,128);
H = freqz(P,Q,W);
subplot (2,1,1)
plot(W,abs(H))
title (‘Magnitude of H[exp(jW)] vs. W’)
ylabel (‘Magnitude’);xlabel(‘frequency W’);
subplot (2,1,2)
plot(W,angle(H))
title(‘Phase of H[exp(jW)] vs. W’)
xlabel(‘frequency W’);ylabel(‘Phase in rad.’)
The script fi le DTFT_H is executed and the results are shown in Figure 5.28.
0246810
0
0.2
0.4
0.6
0.8
1
Magnitude
Phase in rad.
12 14
02468101214
− 4
− 2
0
2
4
frequency W
frequency W
Magnitude of H[exp(jW)] versus W
Phase of H[exp(jW)] versus W
FIGURE 5.28
Magnitude and phase plots of the DTFT of H(ejW) of Example 5.3.