514
Practical MATLAB
® Applications for Engineers
Example 5.3
Let the real sequence h(n) be given by its DTFT as follows:
H e
e
e
e
e
jW
jW
jW
jW
jW
( )
.
.
.
.
.
.
ϭ
ϩ
ϩ
ϩ
ϩ
ϩ
Ϫ
Ϫ
Ϫ
Ϫ
0 007 0 034
0 04
0 04
0 03
0 009
2
3
4
e e
e
e
e
e
j W
jW
j W
j W
j W
Ϫ
Ϫ
Ϫ
Ϫ
Ϫ
ϩ
ϩ
ϩ
ϩ
5
2
3
4
1 2 63
2 81
1 5
0 4
.
.
.
.
Create the script fi le DTFT_H that returns the magnitude and phase plots of the DTFT
of H(e
jW ) 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.
0
2
4
6
8
1 0
0
0.2
0.4
0.6
0.8
1
Magnitude
Phase in rad.
12
14
0
2
4
6
8
1 0
1 2
1 4
−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(e
jW ) of Example 5.3.
CRC_47760_CH005.indd 514
CRC_47760_CH005.indd 514
7/23/2008 1:47:32 PM
7/23/2008 1:47:32 PM
Practical MATLAB
® Applications for Engineers
Example 5.3
Let the real sequence h(n) be given by its DTFT as follows:
H e
e
e
e
e
jW
jW
jW
jW
jW
( )
.
.
.
.
.
.
ϭ
ϩ
ϩ
ϩ
ϩ
ϩ
Ϫ
Ϫ
Ϫ
Ϫ
0 007 0 034
0 04
0 04
0 03
0 009
2
3
4
e e
e
e
e
e
j W
jW
j W
j W
j W
Ϫ
Ϫ
Ϫ
Ϫ
Ϫ
ϩ
ϩ
ϩ
ϩ
5
2
3
4
1 2 63
2 81
1 5
0 4
.
.
.
.
Create the script fi le DTFT_H that returns the magnitude and phase plots of the DTFT
of H(e
jW ) 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.
0
2
4
6
8
1 0
0
0.2
0.4
0.6
0.8
1
Magnitude
Phase in rad.
12
14
0
2
4
6
8
1 0
1 2
1 4
−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(e
jW ) of Example 5.3.
CRC_47760_CH005.indd 514
CRC_47760_CH005.indd 514
7/23/2008 1:47:32 PM
7/23/2008 1:47:32 PM
