PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 611


mag1= abs(H1);
phase1=angle(H1);

figure(1)
subplot(1,2,1)
plot(w,mag1)
xlabel(‘frequency in rad/sec’);
ylabel(‘Magnitude’);
title(‘Magnitude of H(w) vs. w [for R=L=C=1]’);
subplot(1,2,2)
plot(w,phase1*180/pi)
xlabel(‘frequency in rad/sec.’);
ylabel(‘Angle in degrees’);
title(‘Phase of H(w) vs. w [for R=L=C=1]’)

% part(c)
L=1/2;C=1/2; R=1; a=R*L*C;
num2 = R;
den2 = [a L R];
H2 = freqs(num2,den2,w);
mag2 = abs(H2);
phase2 = angle(H2);

figure(2)
subplot(1,2,1)
plot(w,mag2)
xlabel(‘frequency in rad/sec.’);
ylabel(‘Magnitude’);
title(‘Magnitude of H(w) vs. w [for L=C=1/2,R=1]’);
subplot(1,2,2)
plot(w,phase2*180/pi)
xlabel(‘frequency in rad/sec’);
ylabel(‘Angle in degrees’);
title(‘Phase of H(w) vs. w [for L=C=1/2,R=1]’)
disp(‘**************************************************’)
disp(‘******* M A T L A B ***** R E S U L T ************’)
disp(‘**************************************************’)
disp(‘Solution to part (c) ‘)
disp(‘Coefficients of numerator of trans. function [LPF/ with
L=C=1/2,R=1]’)
disp(num2)
disp(‘Coefficients of denominator of trans. function [LPF/lp2lp/wc=2]’)
disp(den2)
tf(num2,den2)
disp(‘**************************************************’)

figure(3)
[P,Q]=lp2lp(num1,den1,2);
Hlp2lp=freqs(P,Q,w);
mag3=abs(Hlp2lp);
phase3=angle(Hlp2lp);
subplot(1,2,1)
plot(w,mag3)
xlabel(‘frequency in rad/sec.’);
Free download pdf