PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 601


axis ([-5e4 5e4 0 1.1])
subplot (2,1,2);
plot (w/(2*pi),angle(Hlp)*180/pi);
xlabel (‘frequency in Hrz’);
ylabel (‘phase in degrees’);
title(‘Phase of H(f) vs. frequency’);
figure(2)
db = 20.*log(abs(Hlp));
subplot(2,1,1);
semilogx(w/(2*pi),db);
ylabel(‘mag.in dbs’);
title(‘ magnitude (dbs) vs. freqs.’);
axis([1e3 1e5 -40 5]);grid on;
subplot(2,1,2);
semilogx(w/(2*pi),angle(Hlp)*180/pi);
title(‘phase ang. vs. freqs.’);
ylabel(‘phase in degrees’);
xlabel(‘frequency, in Hrz’);
axis([1e3 1e5 -80 0]);grid on;
figure(3);
bode(num,den,w)
title(‘Bode plots with argument w’);
figure(4);bode(num,den)
title(‘Bode plots with no w’);
figure(5)
% using standard circuit approach (complex algebra)
XC = 1./(w.*C);
Z = sqrt(R^2+XC.^2);
magHele = abs(XC./Z); phaseHele =-atan(R./XC);
subplot(2,2,1)
plot(w./(2*pi),magHele);
title(‘mag.vs. freq.’);
ylabel(‘magnitude’)
axis([-5e4 5e4 0 1.1]); grid on;
subplot(2,2,2)
plot(w./(2*pi),phaseHele*180/pi);
title(‘phase vs. freq.’);
ylabel(‘phase (in degrees)’);grid on;
subplot(2,2,3);
dbele = 20.*log10(magHele);
semilogx(w./(2*pi),dbele);title(‘mag.(in db) vs. freq. ‘)
ylabel(‘magnitude(db)’);
xlabel(‘frequency in Hrz’);
axis([1e3 1e6 -15 1.0]);grid on;
subplot(2,2,4);
semilogx(w./(2*pi),phaseHele*180/pi);title(‘phase vs. freq. ‘)
xlabel(‘frequency in Hrz’);
ylabel(‘phase(degrees)’); grid on;

Back in the command window, the script fi le LP_fi lter_analysis is executed and the
results are as follows (Figures 6.26 through 6.30):

>> LP _ filter _ analysis
Free download pdf