% Figure 5.41 Feedback Control of Dynamic Systems, 8e 
%                   Franklin, Powell, Emami
%                    
% attitude hold auto pilot for Dakota
% root locus with integral control

clf
s=tf('s');
sysG = 160*(s+2.5)*(s+0.7)/((s^2+5*s+40)*(s^2+0.03*s+0.06));
sysD = (s+3)/(s+20);
sysDG = sysD*sysG;
Kc = 1.5;
sysT = feedback( Kc*sysDG,1 );

% now add integral control

sysL = sysT/s;    % add integral control pole, Eq (5.80)

figure(1)
rlocus(sysL)
grid on
axis([-25 10 -15 15])
hold on
title ('Root Locus vs. K_I for autopilot')

KI = 0.15;
[R1]=rlocus(sysL,KI);
plot(R1,'s', 'MarkerSize', 10, 'MarkerFaceColor','k')
hold off

% now zoom in to origin

figure(2)
rlocus(sysL)
axis([-4 1 -2 2])
grid on
hold on
title('zoomed in')
plot(R1,'s', 'MarkerSize', 10, 'MarkerFaceColor','k')
hold off
figure(1)



% set(gco,'LineWidth',4)
