Académique Documents
Professionnel Documents
Culture Documents
SYSTEM
PID
Contents
ROOT LOCUS
System variable conversions
FREQUENCY
State-Space to Transfer Function
denominator polynomials
In addition, beginning with version 5.0, MATLAB has the ability to represent
(1)
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 1/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
This can be represented in state space form with the following commands:
s = tf('s');
G = (2*s+1)/(4*s^2+3*s+2)
G =
2 s + 1
---------------
4 s^2 + 3 s + 2
vectors as follows:
num = [2 1];
den = [4 3 2];
G = tf(num,den)
G =
2 s + 1
---------------
4 s^2 + 3 s + 2
A state-space model can be extracted from the system variable G with the
following command:
[A,B,C,D] = ssdata(G)
A =
-0.7500 -0.5000
1.0000 0
B =
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 2/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
C =
0.5000 0.2500
D =
system variable, H, with the following commands which returns the following
output showing the relationships between the state, input, and output
variables
H = ss(A,B,C,D)
H =
a =
x1 x2
x1 -0.75 -0.5
x2 1 0
b =
u1
x1 1
x2 0
c =
x1 x2
y1 0.5 0.25
d =
u1
y1 0
To extract a zero-pole-gain model from this system variable, you enter the
following command
[z,p,k] = zpkdata(H,'v')
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 3/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
z =
-0.5000
p =
-0.3750 + 0.5995i
-0.3750 - 0.5995i
k =
0.5000
The 'v' causes the function to return a vectorized version of the zeros and
poles, which is useful for SISO systems.
We can now form another system variable, K, from this zpk representation
K = zpk(z,p,k)
K =
0.5 (s+0.5)
-------------------
(s^2 + 0.75s + 0.5)
[num,den] = tfdata(K,'v')
num =
0 0.5000 0.2500
den =
1.0000 0.7500 0.5000
(Again, the 'v' is useful for SISO systems.) This returns the following
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 4/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
Suppose you have a set of state-space equations and you would like to
convert them to the equivalent transfer function. This is done using the
command
[num,den] = ss2tf(A,B,C,D)
num =
0 0.5000 0.2500
den =
For example, suppose you had the following set of state equations:
(2)
(3)
with
m = 100 kg
b = 50 Ns/m
u = 500 N
If you want to change this to a transfer function, just run the following m-file:
A = [0 1
0 -0.05];
B = [0;
0.001];
C = [0 1];
D = 0;
[num,den]=ss2tf(A,B,C,D)
num =
1.0e-03 *
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 5/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
0 1.0000 0
den =
1.0000 0.0500 0
The numerator, num, will have as many rows as there are outputs (or
rows in the matrix C).
Zeros at Infinity
This last point needs some further explanation. We say that a system has
zeros at infinity if the limit as s->infinity of the value of the transfer function
is equal to zero; this happens whenever you have more poles than zeros.
You will see this in the root locus plot as asymptotes which go to infinity (the
are supposed to be zero end up being very small numbers. It may not seem
like a big deal, but it can cause errors when trying to use the transfer
function later on. You should always check your transfer function, and if
numbers that are 0.0000 show up that are supposed to be zero, rewrite the
A = [0 1 0 0
0 -0.1818 2.6727 0
0 0 0 1
B = [0
1.8182
0
4.5455];
C = [1 0 0 0
0 0 1 0];
D = [0
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 6/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
0];
[num,den]=ss2tf(A,B,C,D)
num =
den =
1.0000 0.1818 -31.1818 6.4786 0
If you look at the numerator, the first and last element of each row are 0,
while the second and fourth element in each row are 0.0000. If you look
closer at each of these elements, you will find that they are not zero, but in
fact some very small number. To see this, enter any of the following
the roots of the numerator polynomials using roots(num(1,:)) and you will
see the roots of the numerator which are almost at infinity but not quite.
after the ss2tf command to get rid of the numbers that are not supposed to
be there:
num(2,3) 0 num(2,5)];
Now all of the small numbers have been replaced with zeros. Always make
sure to look at your transfer function and understand what it means before
The reverse of the command ss2tf is the tf2ss command, which converts a
like this:
[A,B,C,D] = tf2ss(num,den)
A =
-0.1818 31.1818 -6.4786 0
1.0000 0 0 0
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 7/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
0 1.0000 0 0
0 0 1.0000 0
B =
1
0
C =
0 1.8182 0 -44.5460
0 4.5455 0 -0.0000
D =
0
One important fact to note is that although there is only one transfer
equations that describe a system. The tf2ss command returns the state-
convert it back, you will not have the same set of state-space equations you
started with unless you started with matrices in control canonical form.
code:
[A,B,C,D] = tf2ss(num,den)
A =
0 1.0000 0 0
0 0 1.0000 0
B =
1
0
C =
0 1.8182 0 -44.5460
0 4.5455 0 -0.0000
D =
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 8/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
This is obviously not the same set of matrices that were initially used, but
the input-output behavior of this system is the same as that of the previous
one. There are infinitely many ways to represent a given transfer function in
state-space form; MATLAB chooses the control canonical form. The states
There is also a third way to represent a dynamic system, and that is the
pole-zero model. This model is basically the same as the transfer function
model, except that the polynomials have been factored so the poles are all
in the denominator and the zeros are in the numerator. The basic format
(4)
greater than or equal to the number of zeros m. MATLAB can make the
transformations from either state-space or transfer function to the pole-zero
representation. The commands to get the system into zero-pole form are:
[z,p,k] = tf2zp(num,den)
z =
4.9498 0.0000
-4.9498 -0.0000
p =
-5.7753
5.3851
0.2083
k =
1.8182
4.5455
[z,p,k] = ss2zp(A,B,C,D)
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 9/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
z =
4.9498 0.0000
-4.9498 -0.0000
p =
0
-5.7753
5.3851
0.2083
k =
1.8182
4.5455
returns all of the zeros in columns. There should be one column for every
returns a column of gain values. The column should have as many rows as
[z,p,k] = tf2zp(num,den)
z =
4.9498 0
-4.9498 1.6362
p =
0
-5.7753
5.3851
0.2083
k =
1.8182
4.5455
or
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 10/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
A = [0 1 0 0
0 -0.1818 2.6727 0
0 0 0 1
0 -4.545 31.1818 0];
B = [0
1.8182
0
4.5455];
C = [1 0 0 0
0 0 1 0];
D = [0
0];
[z,p,k] = ss2zp(A,B,C,D)
z =
4.9498 1.6362
-4.9498 -0.0000
p =
0
-5.7753
0.2083
5.3851
k =
1.8182
4.5455
There are two columns of zeros, and therefore the k matrix has two rows
As you may have already guessed, if you have a system described by the
pole-zero method, you can convert that to either the state-space model or
the transfer function. To get the state-space model, enter the following
command:
[A,B,C,D] = zp2ss(z,p,k)
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 11/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
A =
1.0000 0 0 0
0 1.0000 0 0
0 0 1.0000 0
B =
0
C =
D =
Again, it is important to note that more than one set of state-space matrices
command are also in control canonical form. For example, take the z, p,
and k matrices you just created and convert them back to state-space:
[A,B,C,D] = zp2ss(z,p,k)
A =
-0.1818 31.1818 -6.4786 0
1.0000 0 0 0
0 1.0000 0 0
0 0 1.0000 0
B =
0
0
C =
D =
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 12/13
9/2/2017 Control Tutorials for MATLAB and Simulink - Extras: Converting Between System Representations
Again, it is important to note that more than one set of state-space matrices
You will recognize this as the same set of matrices you got using the
command, tf2ss.
[num,den] = zp2tf(z,p,k)
num =
den =
You will recognize this as the same transfer function we started out with.
http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_Conversions 13/13