PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

644 Practical MATLAB® Applications for Engineers


MATLAB Solution
% Script file : butt _ implem
[z,p,k] = buttap(3);
disp(‘ ******* R E S U L T S ********’)
disp(‘**********************************’)
disp(‘the poles are :’);disp(p);
[Pn,Qn] = zp2tf(z,p,k); % returns the transf. function
disp(‘The coefficients of the numerator of Hn(s) are: ‘); disp(Pn);
disp(‘The coefficients of the denominator of Hn(s) are: ‘); disp(Qn);
system = tf(Pn,Qn);
system
disp(‘**********************************’)
w =-3:.1:3;
hn = freqs(Pn,Qn,w);
gain=20*log10(abs(hn));
subplot(1,2,1)
plot(w,gain)
xlabel(‘w in rad/sec’)
ylabel(‘gain in db’)
title(‘Normalize filter/magnitude’)
subplot(1,2,2)
plot(w,angle(hn)*180/pi);
xlabel(‘w in rad/sec’);ylabel(‘Phase in degrees’)
title(‘Normalize filter/phase’)
Back in the command window the script fi le butt_implem is executed and the results are
shown as follows (Figure 6.69):
>> butt _ implem
******* R E S U L T S ********
**********************************
the poles are :
-0.5000 + 0.8660i
-0.5000 - 0.8660i
-1.0000
The coefficients of the numerator of Hn(s) are:
0 0 0 1.0000
The coefficients of the denominator of Hn(s) are:
1.0000 2.0000 2.0000 1.0000
Transfer function:
1
---------------------
s^3 + 2 s^2 + 2 s + 1
*********************************************

FIGURE 6.68
Filter’s structure of Example 6.17.


1 Ω

C
Vi(s) Vo(s)

L 1 L 2
Free download pdf