% Atraso de fase via Bode close all clear all w=logspace(-2,2); num1=5; den1=conv([1 1 0],[0.5 1]); [mag1,fase1] = bode(num1,den1,w); mag1=20*log10(mag1); subplot(2,1,1), semilogx(w,mag1,'LineWidth',2) xlabel('Frequência (rad/s)') ylabel('Ganho (dB)') title('APENAS AJUSTE DE GANHO') grid hold on subplot(2,1,1), semilogx([1.82],[0],'ro','LineWidth',3) hold off subplot(2,1,2), semilogx(w,fase1,'LineWidth',2) hold on subplot(2,1,2), semilogx([1e-2 1e2],[-180 -180],'k-.','LineWidth',2) subplot(2,1,2), semilogx([1.82 1.82],[-180 -194.5],'r','LineWidth',3) text(2,-187,'MF = -15^o') xlabel('Frequência (rad/s)') ylabel('Fase (graus)') grid pause subplot(2,1,2), semilogx([1e-2 0.64 0.64],[-140 -140 -280],'m--','LineWidth',2) hold on subplot(2,1,2), semilogx([0.1 0.1],[-140 -180],'m','LineWidth',3) text(0.11,-165,'MF = 40^o') pause subplot(2,1,2), semilogx([1e-2 0.45 0.45],[-128 -128 -280],'r--','LineWidth',2) subplot(2,1,2), semilogx([0.2 0.2],[-128 -180],'r','LineWidth',3) text(0.21,-155,'MF = 52^o') hold off pause hold off figure w=logspace(-3,1); beta = 10; T=10; num2 = 5*[T 1]; den2 = conv([beta*T 1],den1); [mag2,fase2] = bode(num2,den2,w); mag2=20*log10(mag2); subplot(2,1,1), semilogx(w,mag2,'LineWidth',2) hold on subplot(2,1,1), semilogx([0.45],[0],'ro','LineWidth',3) xlabel('Frequência (rad/s)') ylabel('Ganho (dB)') title('COM ATRASADOR DE FASE') grid hold off subplot(2,1,2), semilogx(w,fase2,'LineWidth',2) hold on subplot(2,1,2), semilogx([1e-3 1e1],[-180 -180],'k-.','LineWidth',2) subplot(2,1,2), semilogx([0.45 0.45],[-138.3,-180],'r','LineWidth',3) text(0.27,-155,'MF = 42,7^o') xlabel('Frequência (rad/s)') ylabel('Fase (graus)') grid pause hold off figure [mag1,fase1] = bode(num1,den1,w); mag1=20*log10(mag1); subplot(2,1,1), semilogx(w,mag1,'k--','LineWidth',2) hold on subplot(2,1,1), semilogx(w,mag2,'b','LineWidth',2) subplot(2,1,1), semilogx([0.45],[0],'ro','LineWidth',3) subplot(2,1,1), semilogx([1.82],[0],'bo','LineWidth',3) xlabel('Frequência (rad/s)') ylabel('Ganho (dB)') title('APENAS AJUSTE DE GANHO x ATRASADOR DE FASE') grid hold off subplot(2,1,2), semilogx(w,fase1,'k--','LineWidth',2) hold on subplot(2,1,2), semilogx(w,fase2,'b','LineWidth',2) subplot(2,1,2), semilogx([1e-3 1e1],[-180 -180],'k-.','LineWidth',2) subplot(2,1,2), semilogx([0.45 0.45],[-138.3,-180],'r','LineWidth',3) text(0.27,-155,'MF = 42,7^o') xlabel('Frequência (rad/s)') ylabel('Fase (graus)') grid