Digital Signal Processing Reference
In-Depth Information
1
0.5
0
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Frequency (Hz)
1
0.5
0
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Frequency (Hz)
0
-50
-100
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Frequency (Hz)
FIGURE 8.28
Frequency responses. The line of “x”s represent the frequency responses of the analog filter; the solid line
represents the frequency responses of the designed digital filter.
b. The MATLAB code is listed in Program 8.12. The first and third plots in Figure 8.28 show comparisons of the
magnitude and phase frequency responses. The shape of the magnitude response (first plot) closely matches
that of the analog filter, while the phase response (third plot) differs from the analog phase response in this
example.
Program 8.12. MATLAB program for Example 8.15.
% Example 8.15.
% Plot the magnitude responses
j H(s) j
and
j H(z) j
% For the Laplace transfer function H(s)
f ¼ 0:0.1:5;T ¼ 0.1;
% Frequency range and sampling interval
w ¼ 2*pi*f;
% Frequency range in rad/sec
hs ¼ freqs([2], [1 2],w);
% Analog frequency response
phis ¼ 180*angle(hs)/pi;
% For the z-transfer function H(z)
hz ¼ freqz([0.2],[1 -0.8187],length(w)); % Digital frequency resoonse
hz_scale
¼
freqz([0.1813],[1 -0.8187],length(w)); % Scaled digital mag. response
phiz
180*angle(hz)/pi;
% Plot magnitude and phase responses.
subplot(3,1,1), plot(f,abs(hs),
¼
kx
,f, abs(hz),
k-
),grid; axis([0 5 0 1.2]);
'
'
'
'
xlabel(
Frequency (Hz)
); ylabel(
Mag. Responses
)
'
'
'
'
subplot(3,1,2),
plot(f,abs(hs),
kx
,f,
abs(hz_scale),
k-
),grid;
axis([0
5
'
'
'
'
0 1.2]);
 
Search WWH ::




Custom Search