clear all; close all;
K = 1;
omegan = 10;
zeta = 0.5;
num = [ 0 0 K*omegan^2 ];
den = [ 1 2*zeta*omegan omegan^2 ];
Ki1 = 1.0;
Ki2 = 3.0;
Ki3 = 9.0;
numc1 = [ 0 Ki1 ];
numc2 = [ 0 Ki2 ];
numc3 = [ 0 Ki3 ];
denc = [ 1 0 ];
sys = tf( num, den );
c1 = tf( numc1, denc );
c2 = tf( numc2, denc );
c3 = tf( numc3, denc );
sysL1 = c1*sys;
sysL2 = c2*sys;
sysL3 = c3*sys;
w = logspace(-1, 3, 1000);
[gainL1 phaseL1 wL1] = bode(sysL1, w);
gainL1 = gainL1(:);
gainL1dB = 20*log10(gainL1);
phaseL1 = phaseL1(:);
subplot(2,3,1)
semilogx(wL1, gainL1dB);
xlim([10^(-1),10^3])
ylim([-50 50])
xticks([10^(-1) 10^(0) 10^(1) 10^(2) 10^(3)])
yticks([-40 -20 0 20 40])
grid;
xlabel('Frequency (rad/s)');
ylabel('Gain [dB]');
title('K_i = 1');
subplot(2,3,4)
semilogx(wL1, phaseL1);
xlim([10^(-1),10^3])
ylim([-270 -90])
xticks([10^(-1) 10^(0) 10^(1) 10^(2) 10^(3)])
yticks([-270 -225 -180 -135 -90])
grid;
xlabel('Frequency (rad/s)');
ylabel('Phase [deg]');
[gainL2 phaseL2 wL2] = bode(sysL2, w);
gainL2 = gainL2(:);
gain2dB = 20*log10(gainL2);
phaseL2 = phaseL2(:);
subplot(2,3,2)
semilogx(wL2, gain2dB);
xlim([10^(-1),10^3])
ylim([-50 50])
xticks([10^(-1) 10^(0) 10^(1) 10^(2) 10^(3)])
yticks([-40 -20 0 20 40])
grid;
xlabel('Frequency (rad/s)');
title('K_i = 3');
subplot(2,3,5)
semilogx(wL2, phaseL2);
xlim([10^(-1),10^3])
ylim([-270 -90])
xticks([10^(-1) 10^(0) 10^(1) 10^(2) 10^(3)])
yticks([-270 -225 -180 -135 -90])
grid;
xlabel('Frequency (rad/s)');
[gainL3 phaseL3 wL3] = bode(sysL3, w);
gainL3 = gainL3(:);
gainL3dB = 20*log10(gainL3);
phaseL3 = phaseL3(:);
subplot(2,3,3)
semilogx(wL3, gainL3dB);
xlim([10^(-1),10^3])
ylim([-50 50])
xticks([10^(-1) 10^(0) 10^(1) 10^(2) 10^(3)])
yticks([-40 -20 0 20 40])
grid;
xlabel('Frequency (rad/s)');
title('K_i = 9');
subplot(2,3,6)
semilogx(wL3, phaseL3);
xlim([10^(-1),10^3])
ylim([-270 -90])
xticks([10^(-1) 10^(0) 10^(1) 10^(2) 10^(3)])
yticks([-270 -225 -180 -135 -90])
grid;
xlabel('Frequency (rad/s)');