% FILE: ogataExampleRootLocus011119b.m - works
% DATE: 01/11/19 11.43
% AUTH: P.Oh
% DESC: Root Locus plot for lag compensated system

% Ogata Example 7-2 has a unity feedback system 

%              1.06               1.06
%   G(s) = -------------- = -----------------
%           s(s+1)(s+2)      s^3 + 3s^2 + s


% The OLTF for the lag compensated system is given by 


%                Kc(s+0.05)       1.06             
%   Gc(s)*G(s) = ---------- *  -------------- 
%                (s+0.005)       s(s+1)(s+2)  
%
%
%                   Kc(s+0.05)*1.06          Kc(1.06s + 0.053)
%              = ---------------------- = ---------------------------
%                 s(s+0.005)(s+1)(s+2)    s^4+3.005s^3+2.015s^2+0.01s
%


% Define OLTF

GLagCompensatedTFNum = [1.06 0.053];
GLagCompensatedTFDen = [1 3.005 2.015 0.01 0];

GLagCompensatedTF = tf(GLagCompensatedTFNum, GLagCompensatedTFDen)

% In factored (i.e. zero and pole) form

% zpk(G)

% Display root locus for OLTF lag compensated version.  Use rlocusplot so can add title etc

handleRootLocusPlot = rlocusplot(GLagCompensatedTF);
plotOptions = getoptions(handleRootLocusPlot);
plotOptions.Title.String = 'Ogata Fig 7-15b; RL for Lag Compensated OLTF';
plotOptions.XLim = [-4 2];
plotOptions.YLim = [-3 3];
setoptions(handleRootLocusPlot, plotOptions);


