PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

612 Practical MATLAB® Applications for Engineers


ylabel(‘Magnitude’);
title(‘Magnitude of H(w) vs. w [using lp2lp]’);
subplot(1,2,2)
plot(w,phase3*180/pi)
xlabel(‘frequency in rad/sec’);
ylabel(‘Angle in degrees’);
title(‘Phase of H(w) vs. w [using lp2lp]’)
disp(‘**************************************************’)
disp(‘Solution to part (e) ‘)
disp(‘Coefficients of the numerator of the trans. function [wc=2]’)
disp(P)
disp(‘Coefficients of the denominator of the trans. function [wc=2]’)
disp(Q)
tf(P,Q)
disp(‘**************************************************’)

%part(f),solution using Butter/norm.LPF
[z,p,k] = buttap(2);
[Pn,Qn] = zp2tf(z,p,k);
disp(‘**************************************************’)
disp(‘Solution to part (f) ‘)
disp(‘Coefficients of the numerator of the trans. function
[butter/LPF/wc=1]’)
disp(Pn)
disp(‘Coefficients of the denominator of the trans. function
[butter/LPF/wc=1]’)
disp(Qn)
tf(Pn,Qn)
disp(‘**************************************************’)

figure(4)
w=0:.1:3;
Hbut=freqs(Pn,Qn,w);
mag4 = abs(Hbut);
phase4 = angle(Hbut);
subplot(1,2,1)
plot(w,mag4)
xlabel(‘frequency in rad/sec.’);
ylabel(‘Magnitude’);
title(‘Magnitude of H(w) vs. w [Butter/wc=1]’);
subplot(1,2,2)
plot(w,phase4*180/pi)
xlabel(‘frequency in rad/sec’);
ylabel(‘Angle in degrees’);
title(‘Phase of H(w) vs. w [Butter/wc=1]’)

% part(g),transforming the butter/LPF using lp2lp
% with cut off frequency,wc=2 rad/sec
[Pl,Ql] = lp2lp(Pn,Qn,2);
disp(‘***************************************************’)
disp(‘Solution to part (g) ‘)
disp(‘Coefficients of the numerator of the transf. function
[butter/wc=2rad/sec]’)
disp(Pl)
Free download pdf