% FILE: rootLocusNxtMotorWheel1_0a_020619.m
% DATE: 02/06/19 12:54
% AUTH: P.Oh
% DESC: Root Locus plot for the NXT Motor/Wheel
% VERS: 1.0a - Root Locus (uses System ID model)
% REFS: http://ctms.engin.umich.edu/CTMS/index.php?example=CruiseControl&section=ControlRootLocus
%       rootLocusIntuitive3_0_012319a.m

% The plant transfer function resulting from 01/31/19 Matlab System ID 

%               64.31                                  9.2 * 6.998
%   Gp(s) = ------------ or more explicitly  Gp(s) = --------------- where kDC = 9.2
%             (s+6.998)                                 (s+6.998)


% Define Plant TF

gpTfNum = [64.31];
gpTfDen = [1 6.998];

gpTf = tf(gpTfNum, gpTfDen)

gTf = gpTf; % let gTf be the variable to use for TF we want plotted

handleRootLocusPlot = rlocusplot(gTf);
plotOptions = getoptions(handleRootLocusPlot);
plotOptions.Title.String = 'RL for NXT Motor/Wheel';
plotOptions.XLim = [-10000 0];
% plotOptions.YLim = [-0.4 0.4];
setoptions(handleRootLocusPlot, plotOptions);

% rlocfind allows one to use mouse to identify gains and poles
[K, P] = rlocfind(gTf)
