% Fig. 5.28b  Feedback Control of Dynamic Systems, 8e 
%             Franklin, Powell, Emami
% script for right side of Figure 5.28

clf 
s=tf('s');
sysG=1/(s*(s+1)); 
sysD1=(s+2)/(s+13);
sysD2=91*(s+0.05)/(s+0.01);
sysD=sysD1*sysD2;
sysOL=sysG*sysD;
n=[1 2]; 
d=conv([1 1 0],[1 13]);
nc=[1 .05];
dc=[1 .01];
nol=conv([0 0 n],nc);
dol=conv(d,dc);
%sysOL=tf(nol,dol);  % alternate way for TF using Num and Den
K=0:.00002:.05;
rlocus(sysOL,K); 
 hold on
 title('Root locus for lead plus lag')
  axis([-.14 .04 -.07 .07])
 z=0.1:.2:.9;
 wn=.05:.05:.2;
 sgrid(z, wn)
 dcl=91*nol+dol;
 r=roots(dcl); % shows that extra  root from Lag comp is almost right on the zero.
 plot(r,'*')  
 hold off
 
% set(gco,'LineWidth',4)