Basic MATLAB Commands For Control
Basic MATLAB Commands For Control
If we want to determine its value for a particular value of t, (say t = 10) then,
the following command should be executed.
t=10;
y=subs(f);
Examples:
x3 + 3x + 2 x2 + 5x + 6 = f1 (x)f2 (x)
Solution
f1=[1 3 2];
f2=[1 5 6];
f3=conv(f1,f2);
Similarly
f1=[1 9 7 5 2];
x4 + 9x3 + 7x2 + 5x + 2 x2 − 4x + 6 = f1 (x)f2 (x)
=⇒ f2=[1 -4 6];
f3=conv(f1,f2);
s2 + 8s + 15
G=
s4 + 18s3 + 104s2 + 192s
MATLAB for Control: A Beginners’ Guide 11 / 66
MATLAB for Control: A Beginners’ Guide 12 / 66
Transfer Function Representation
Given
Y (s) 25
G(s) = = 2
U (s) s + 4s + 25
This can be represented by using
MATLAB Function:tf
Method-I Method-II
Given
Y (s) 3(s − 1)
G(s) = =
U (s) (s − 2 + i)(s − 2 − i)
This can be represented by using
MATLAB Function:zpk
zeros=[1];
poles=[2-i 2+i];
Gain=3;
G=zpk(zeros,poles,gain);
s2 + 6s + 5
G(s) =
s4 + 7s3 + 80s2 + 204s
into zero-pole-gain format.
Given
1 0 1
ẋ = Ax + Bu A= ,B = ,
−2 1 0
y = Cx + Du C= 3 −2 , D = 0
MATLAB Function:ss
A=[1 0;-2 1];
B=[1 0]’;
C=[3 -2];
D=[0]; sys=ss(A,B,C,D);
I The relation between the output C(s) and input R(s) is given by
C(s)
= G1 (s)G2 (s) =⇒ C(s) = G1 (s)G2 (s)R(s)
R(s)
I Determine the equivalent block using MATLAB if
s+4 4
G1 (s) = , G2 (s) = 2
s2 + 2s + 10 s + 5s + 2
I The relation between the output C(s) and input R(s) is given by
C(s)
= G1 (s) + G2 (s) =⇒ C(s) = [G1 (s) + G2 (s)] R(s)
R(s)
I Determine the equivalent block using MATLAB if
s+4 4
G1 (s) = 2 , G2 (s) = 2
s + 2s + 10 s + 5s + 2
num1=[1 4]; den1=[1 2 10]; %First Block
num2=[4]; den2=[1 5 2]; %Second Block
sysG1=tf(num1,den1); % First Transfer Function G1 (s)
sysG2=tf(num2,den2); % Second Transfer Function G2 (s)
sysEq=parallel(sysG1,sysG2); % Equivalent Single Transfer Function
MATLAB for Control: A Beginners’ Guide 37 / 66
MATLAB for Control: A Beginners’ Guide 38 / 66
Example-1:Simulating Cascaded Feedback Systems-1
I Consider the figure below which consists of 2-systems with transfer functions
G1 (s) and G2 (s)
I The relation between the output C(s) and input R(s) is given by
C(s) G1 (s) G1 (s)
= =⇒ C(s) = R(s)
R(s) 1 + G1 (s)G2 (s) 1 + G1 (s)G2 (s)
Objective: To compute the output c(t) of the closed loop system for step
reference i.e when r(t) = 1(t).
I Consider the unity feedback system consisting of the controller Gc (s) and system
G(s) which are given by
Objective: To compute the output y(t) of the closed loop system for step
reference i.e when r(t) = 1(t).
Step-1: Determine the equivalent block using MATLAB. Let
s+1 1
Gc (s) = , G2 (s) =
s+2 500s2
Poles which are closer to the jω-axis are called dominant poles and those
far away from the jω-axis are called non-dominant or insignificant poles
Rule of Thumb
If the magnitude of the real part of the pole is at least 5 to 10 times that of
a dominant pole or a pair of complex dominant poles, then the pole may be
regarded as non-dominant (insignificant) from the perspective of preserving
transient response with acceptable error.
a. Similar to the poles, the zeros which are close to the jω-axis in the left-half
s-plane affect the transient response significantly compared to the zeros which
are located far away from the jω-axis ( relative to dominant poles).
b. Although,the regions shown in Figure 1 give us a rough idea about the dominant
and non-dominant regions in the s-plane, while designing the controllers ( e.g.
the pole placement controller), we often desire the dominant poles to be located
near the regions shown in Figure 2 which will ensure ξ = 0.707.
Figure: Regions of dominant and insignificant poles in the s-plane for purpose of design
Addition of a Zero:
If we add a zero at s = −c to the closed-loop system, the system becomes
C(s) K(s + c) K(s + c)
T(s) = = 2 =⇒ C(s) = R(s)
R(s) (s + a1 s + a2 ) (s2 + a1 s + a2 )
K(s + c) Kc
c(∞) = css = lim sC(s) = lim =
s→0 s→0 (s2 + a1 s + a2 ) a2
Thus the the steady state error of the modified system is increased. If we want
to have the same steady state error, as of the original system, the gain K of the
modified system should be divided by the factor c.