MATLAB Session 6 Results

The collection of MATLAB statements and screen display:

>> %Root locus plots
>> p=[1 6 11 6];
>> roots(p)

ans =

   -3.0000
   -2.0000
   -1.0000
New feature in MATLAB 6
If you click right on a locus, the position is marked by a black square, and a small subwindow will pop out, reporting the gain, the pole coordinates, the damping ratio and percent overshoot of the chosen closed-loop pole. If you drag the small black square along the locus, the information in the subwindow will be updated instantaneously.

For all practical purposes, this new feature replaces the need of the sgrid() and rlocfind() functions.

>> G=tf(1,p);
>> rlocus(G)

>> %Adding an open-loop zero to cancel the open-loop pole at -1
>> G=tf([1 1],p);
>> rlocus(G)

>> %Two more examples
>> G=zpk([],[-1 -3],1)     %Second order example

Zero/pole/gain:
     1
-----------
(s+1) (s+3)

>> rlocus(G)

>> G=zpk([],[-1 -2 -3],1)  %Third order example

Zero/pole/gain:
        1
-----------------
(s+1) (s+2) (s+3)

>> rlocus(G)

Note: This result is typical. The MATLAB default plot does not necessarily cross the imaginary axis. If you want to find the ultimate gain with rlocfind(), you will need to do the root locus plot with your own gain vector -- what will be illustrated below.

>> %The optional reading section
>> q=[2/3 1];
>> p=[1 6 11 6];
>> poles=roots(p)'

poles =

   -3.0000   -2.0000   -1.0000

>> zeros=roots(q)'

zeros =

   -1.5000

>> G=tf(q,p)

Transfer function:
     0.6667 s + 1
----------------------
s^3 + 6 s^2 + 11 s + 6

>> %Defining our own gain vector. May take some trial-and-error
>> %to get good plotting results.
>> k=0:0.5:100;

>> rlocus(G,k);

>> %Alternate route of doing the plot that can be more instructive
>> %at the learning stage
>> r=rlocus(G,k);
>> plot(r,'y.')    %Deviation from text. Forcing all dots to be yellow here.
>> hold
Current plot held
>> py=[0 0 0];
>> qy=0;
>> ax=[0 0]; ay=[-4 4];
>> plot(poles,py,'x', zeros,qy,'o', ax,ay,'-')

>> %Another deviation from text. Using our own axis to better
>> %see the open-loop pole at -3.
>> axis([-4 0 -10 10]);

>> xlabel('Re'), ylabel('Im')
>> hold off

>> %Another alternative that will give the same result
>> plot(r,'y.')
>> hold
Current plot held
>> pzmap(G)
 

>> %Drawing damping ratio and natural frequency grid lines
>> rlocus(G)
>> sgrid(0.7,1)
>> %try rlocfind(G) yourself




New feature in MATLAB 6
The sisotool has replaced the older rltool.

>> %Launching the SISO graphics design
>> %tool (with the root locus view)
>> sisotool(' rlocus')
>> %or if you know ahead of time the plant function to be used already
>> sisotool(' rlocus', G)

What you find is a really nicely desgined panel of tools. Its usage is pretty self-explanantory and point-and-click. When the sisotool is launched, it will ask if you would like to see Help. Say yes if this is the first time you use the tool or if you need on-line help. Here are some brief comments:

Note: As mentioned in text, you could do all the plotting below using sisotool. But using the statements are much(!) faster and probably more instructive while you are learning the root locus concept the first time.

>> %Root locus plots of sample control systems
>> %First, a first order open-loop process and P and PD controllers
>> Gp=tf(1,[1 1]);    % open loop pole at -1, and Gc = Kc
>> subplot(221), rlocus(Gp)
>> taud=2;    % open loop zero at -1/2
>> Gc=tf([taud 1],1);
>> subplot(222), rlocus(Gc*Gp)
>> taud=1/2;    % open loop zero at -2
>> Gc=tf([taud 1],1);
>> subplot(223), rlocus(Gc*Gp)

>> %Plots for PI controllers
>> figure(2)
>> subplot(221), rlocus(Gp) % repeat Gc=Kc
>> taui=2;    % open loop zero at -1/2
>> Gc=tf([taui 1],[taui 0]);
>> subplot(222), rlocus(Gc*Gp)
>> taui=1/2;    % open loop zero at -2
>> Gc=tf([taui 1],[taui 0]);
>> subplot(223), rlocus(Gc*Gp)
>> %An ideal PID controller
>> figure(3)
>> subplot(221), rlocus(Gp) % repeat Gc = Kc
>> op_pole=[0]; % open loop pole at 0
>> op_zero=[-0.3 -0.8]; % both zeros "less" than -1
>> Gc=zpk(op_zero,op_pole,1);
>> subplot(222), rlocus(Gc*Gp)
>> op_zero=[-1.5 -3]; % both zeros "larger" than -1
>> Gc=zpk(op_zero,op_pole,1);
>> subplot(223), rlocus(Gc*Gp)
>> op_zero=[-0.5 -1.8]; % one zero in each region
>> Gc=zpk(op_zero,op_pole,1);
>> subplot(224), rlocus(Gc*Gp)

>> %Control systems with a second order overdamped open-loop process
>> %First, P and PD controllers
>> figure(1)
>> p=poly([-1 -2]); % open loop poles -1, -2
>> Gp=tf(1,p);
>> subplot(221), rlocus(Gp) % proportional control
>> taud=2; % open loop zero at -1/2
>> Gc=tf([taud 1],1);
>> subplot(222), rlocus(Gc*Gp)
>> taud=2/3; % open loop zero at -1.5
>> Gc=tf([taud 1],1);
>> subplot(223), rlocus(Gc*Gp)
>> taud=1/3; % open loop zero at -3
>> Gc=tf([taud 1],1);
>> subplot(224), rlocus(Gc*Gp)

>> %PI controllers
>> figure(2)
>> subplot(221), rlocus(Gp) % re-do proportional control
>> taui=2; % open loop zero at -1/2
>> Gc=tf([taui 1],[taui 0]);
>> subplot(222), rlocus(Gc*Gp)
>> taui=2/3; % open loop zero at -1.5
>> Gc=tf([taui 1],[taui 0]);
>> subplot(223), rlocus(Gc*Gp)
>> taui=1/3; % open loop zero at -3
>> Gc=tf([taui 1],[taui 0]);
>> subplot(224), rlocus(Gc*Gp)