Example 6.11

MATLAB code for example 6.11 from the book "Regeltechniek voor het HBO"

Fourteen examples of systems and their rootlocus

Copyright (c) 2018, Studieboeken Specialist Permission is granted to copy, modify and redistribute this file, provided that this header message is retained.
Table of Contents
Figure 6.13 shows common root loci based on the block diagram of figure 6.12. The course of the loci can be easily checked with the construction rules, but it is much easier to let the computer do that (see example 6.12). But remember: in a root locus ONLY AND ONLY poles are displayed, no zeros! The "little circle" (or circles) you see is/are the pole(s) of the system for and in fact it is wrong to use the symbol of a zero in this/these point(s). So be aware of this and don't confuse a root locus with the pole and zero plot of a system (where there can be zeros).

Initialisation

clear all variables from Workspace
clear variables;
close all;
 
% Define 's' variable
s=tf('s');
% Disable warnings on complex valued poles and zeros
warning off Control:ltiobject:TFComplex

Create models:

First we define each of the models using the zeros, poles and as depicted in fig 6.13 in the book.
a) one pole
b) one pole and one zero (is pole for !)
c) one pole and one zero (is pole for !)
d) two different real poles
e) two coincident real poles
f) two complex conjugated poles
g) two poles and one zero (is pole for !)
h) two poles and one zero (is pole for !)
i) two poles and one zero (is pole for !)
j) two poles and one zero (is pole for !)
k) three poles
l) three coincident real poles
m) three poles and one zero (is pole for !)
n) three poles and one zero (is pole for !)
% Define the models using a structure
Hmodels = struct('Proces',s,'Name','Procesname');
 
% Fill the structure
Hmodels(1).Name='fig 6.13a';
Hmodels(1).Proces=1/(s+8);
 
Hmodels(2).Name='fig 6.13b';
Hmodels(2).Proces=1*(s+8)/(s+3);
 
Hmodels(3).Name='fig 6.13c';
Hmodels(3).Proces=1*(s+3)/(s+8);
 
Hmodels(4).Name='fig 6.13d';
Hmodels(4).Proces=1/((s+2)*(s+8));
 
Hmodels(5).Name='fig 6.13e';
Hmodels(5).Proces=1/((s+5)*(s+5));
 
Hmodels(6).Name='fig 6.13f';
Hmodels(6).Proces=1/((s+5+3*1i)*(s+5-3*1i));
 
Hmodels(7).Name='fig 6.13g';
Hmodels(7).Proces=2*(s+6)/((s+2)*(s+8));
 
Hmodels(8).Name='fig 6.13h';
Hmodels(8).Proces=2*(s+2)/((s+6)*(s+8));
 
Hmodels(9).Name='fig 6.13i';
Hmodels(9).Proces=4*(s+8)/((s+2)*(s+6));
 
Hmodels(10).Name='fig 6.13j';
Hmodels(10).Proces=4*(s+6)/((s+6+3*1i)*(s+6-3*1i));
 
Hmodels(11).Name='fig 6.13k';
Hmodels(11).Proces=400/((s+2)*(s+4)*(s+6));
 
Hmodels(12).Name='fig 6.13l';
Hmodels(12).Proces=400/((s+4)*(s+4)*(s+4));
 
Hmodels(13).Name='fig 6.13m';
Hmodels(13).Proces=10*(s+6)/((s+2)*(s+4)*(s+8));
 
Hmodels(14).Name='fig 6.13n';
Hmodels(14).Proces=20*(s+8)/((s+2)*(s+4)*(s+6));
 

Plot root locus, bodediagram and stepresponse

First choose the system you want to analyze
%Choose system to analyze
FigChoice='i';
 
% Determine model number from the given letter
ModelNo=double(FigChoice)-double('a')+1;
H_analyze=Hmodels(ModelNo).Proces;
FigName=Hmodels(ModelNo).Name;
 
% Determine Kpn
[Z,P,Kpn]=zpkdata(H_analyze);
 
% plot the rootlocus
figure(101);
h=rlocusplot(H_analyze);
grid on;
XLim=[-14 2];
YLim=[-8 8];
 
% Fine tune the look of the plot
% get the handle to the plot options
p=getoptions(h);
% Zoom in
p.XLim=XLim;
p.YLim=YLim;
% Adjust Title
p.Title.String=['Root Locus of ', FigName];
% write the options to the figure
setoptions(h,p);
 

Generate MATLAB figure(s) for usage in the book

Init create Enhanced Figures

Close all the earlier enhanced figures with a certain tag
EnhancedFig = findobj(0, 'Tag', 'EnhancedImage');
close(EnhancedFig);

Enhance the figures for possible use in the book

figure1=figure(1001);
% Give it a tag
set(gcf, 'Tag','EnhancedImage');
% create the plot again but now with rlocusplot to return a figure handle
h=rlocusplot(H_analyze);
grid on;
 
% get the handle to the plot options
p=getoptions(h);
% Zoom in
p.XLim=XLim;
p.YLim=YLim;
% Adjust Title
p.Title.String=['Root Locus of ', FigName];
% write the options to the figure
setoptions(h,p);
 
% Calculate location axis
Xoffset=0.14; % left part of the figure window not used by the graph
Scale=0.8; % part of the whole figure window used by the graph
Vaxis_loc=Xoffset+0.8*abs(XLim(1))/abs(XLim(1)-XLim(2));
% Place axis labels
omega = char(969); % Greek letter omega
lambda = char(955); % Greek letter lambda
annotation(figure1,'textarrow',[Vaxis_loc Vaxis_loc],...
[0.79 0.86],'String',{omega});
annotation(figure1,'textarrow',[0.9-0.07 0.9],...
[0.48 0.48],'String',{lambda});
annotation(figure1,'textbox',...
[Vaxis_loc 0.52 0.077 0.051],...
'String',{'s-vlak'},...
'LineStyle','none',...
'FitBoxToText','off');
annotation(figure1,'textbox',...
[Vaxis_loc-0.03 0.46 0.0306 0.042],...
'String','0',...
'LineStyle','none',...
'FitBoxToText','off');
annotation(figure1,'textbox',...
[Vaxis_loc+0.01 0.81 0.077 0.0517],...
'String',['Kpn=', num2str(Kpn)],...
'LineStyle','none',...
'FitBoxToText','off');