Fundamentals of Linear Control
Mauricio de Oliveira
Supplemental material for Chapter 5
Before You Start
In this script you will perform calculations with transfer-functions. In addition to the commands already used, the following MATLAB commands will be used:
- ss, to create state-space objects;
- tzero, to calculate the transmission zeros of a MIMO system.
You will also use the following auxiliary commands:
- minreal, to perform pole-zero cancellations;
5.3 Minimal State-Space Realization
The command ss creates a state-space object that MATLAB can work with. The arguments of ss are the state-space realization (A,B,C,D) matrices. For example:
% State space model (5.9)
alpha = 1
beta = 1
gamma = 1
A = [0 1; 0 0]
B = [1; beta]
C = [alpha 1]
D = gamma
g = ss(A,B,C,D)
construct a state-space object g that represents the transfer-function in (5.9).
One can transform back and forth between state-space and transfer-functions. For example, tf converts the state-space object into a transfer-function object:
% to transfer-function
tf(g)
One can directly calculate various properties of state-space objects without explicitly converting to transfer-function. For example:
pole(g)
calculate the poles and
zero(g)
calculates the zeros of g.
One operates with state-space objects the same way as with transfer-function objects. For example the command step calculates the step response and produces a plot as in:
step(g)
and bode produces a representation of the frequency response (more about this on Chapter 7):
bode(g)
Note that the step response diverges since g is not asymptotically stable (it has two poles at the origin). It can be stabilized by unit feedback
h = feedback(g,1)
which produces a closed-loop system with poles at
pole(h)
If we redo the calculation with
% Model (5.9)
alpha = 0;
beta = 1;
gamma = 1;
A = [0 1; 0 0];
B = [1; beta];
C = [alpha 1];
D = gamma;
g = ss(A,B,C,D)
and calculate the transfer-function
tf(g)
note how the order of the transfer-function is now 1 instead of 2. As discussed in Section 5.3, the reason is lack of controllability.
A minimal realization associated with this state-space realization is obtained using:
minreal(g)
Note that without controlability the system can no longer be stabilized under feedback. Indeed
h = feedback(g,1)
pole(h)
reveal that one of the poles remain at the origin.
We can use the above commands to verify that the example (5.11)
% Model (5.11)
A = -eye(2);
B = 2*eye(2);
C = -[0 1/2;1 1/2];
D = [1 1; 1 1];
g = ss(A,B,C,D)
has the transfer-function shown in Section 5.3
% to transfer-function
tf(g)
which appears to be of first order. We can calculate the poles
pole(g)
and zeros
tzero(g)
Note that we use tzero because this is a MIMO system. A call to
minreal(g)
does not reduce the system since it is already minimal.
5.5 Simple Pendulum
Consider the simple pendulum with parameterrs:
m = 0.5
l = 0.3
r = l/2
b = 0
g = 9.8
J = m*l^2/12
Jr = J + m*r^2
and the block-diagram corresponding to Fig. 5.12:
This diagram is implemented in simulink as the model 'SimplePendulumWithoutFeedback.mdl'. It can be simulated directly in simulink or using the commands:
T = 10 % Simulation time
theta0 = pi/6 % Initial angle
tauBar = 0 % External torque
[t,x,y]=sim(['SimplePendulumWithoutFeedback'], T);
The output y corresponds to the angle θ that we plot next:
plot(t,y), grid
ylabel('\theta (rad)')
xlabel('t (s)')
Since there is no damping, , the behaviour in this case is that of an oscillator.
We can simulate other scenarios easily. For example, we can add damping:
b = 0.01
[t,x,y]=sim(['SimplePendulumWithoutFeedback'], T);
plot(t,y), grid
ylabel('\theta (rad)')
xlabel('t (s)')
or simulate starting near the unstable equilibrium :
theta0 = pi-0.01 % Initial angle
[t,x,y]=sim(['SimplePendulumWithoutFeedback'], T);
plot(t,y), grid
ylabel('\theta (rad)')
xlabel('t (s)')
which shows the pendulum diverging from that equilibrium towards the stable equilibrium . Likewise, we can add an external torque:
theta0 = 0 % Initial angle
tauBar = 0.1 % External torque
[t,x,y]=sim(['SimplePendulumWithoutFeedback'], T);
plot(t,y), grid
ylabel('\theta (rad)')
xlabel('t (s)')
which will shift the equilibrium away from zero.
model = 'SimplePendulumWithoutFeedback';
open_system(model);
Simulink can also do many other things with your model, including linearization. For example, one can calculate linearized state-space and transfer-function models around the equilibrium using:
theta0 = 0; % Stable equilibrium
b = 0.01; % No damping
io(1) = linio([model '/Gain 3'],1,'input');
io(2) = linio([model '/Integrator 2'],1,'output');
G0 = tf(linearize(model,io))
As shown in the book, we expect to be asymptotically stable:
pole(G0)
Likewise, linearizing around the unstable equilibrium :
theta0 = pi; % Unstable equilibrium
b = 0.01; % No damping
io(1) = linio([model '/Gain 3'],1,'input');
io(2) = linio([model '/Integrator 2'],1,'output');
Gpi = tf(linearize(model,io))
we obtain the transfer-functon :
pole(Gpi)
which has an unstable pole on the right-hand side of the complex plane.