You are on page 1of 28

OBTAINING STATE-SPACE MODEL OF A COMPLEX SYSTEM FROM

TRANSFER FUNCTIONS OR VICE-VERCA


Prof. Dr. Mehmet Akbaba

Obtaining transfer function of a dynamic from its state-space model


Transfer function is described between single input and single output of a
system and it is equal to the ratio of the Laplace transform of the output
divided to the Laplace transform of the input.
Assuming a dynamic system has following state-space model:
ẋ1 10 5 𝑥1 4 0 𝑢1 (𝑡)
= 𝑥 +
ẋ2 5 −6 2 −1 3 𝑢2 (𝑡)

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 1


The system has two outputs, y1(t) and y2(t), and two input excitation
function, u1(t) and u2(t). Therefore, there are four transfer functions
as follows:
𝒚𝟏 (𝒕) 𝒚𝟐 (𝒕)
𝒉𝟏 𝒔 = , 𝒉𝟐 𝒔 = ,
𝒖𝟏 (𝒕) 𝒖𝟏 (𝒕)
𝒚𝟏 (𝒕) 𝒚𝟐 (𝒕)
𝒉𝟑 𝒔 = and 𝒉𝟒 𝒔 =
𝒖𝟐 (𝒕) 𝒖𝟐 (𝒕)
In MATALAB to get these transfer functions we use a
MATLAB function given below:

ss2tf
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 2
which means state-space to transfer function.
Syntax is as follows:
[num, den] = ss2tf(a,b,c,d,1)
Here :
num: numerator
den: denominator
a, b, c and d: state-space model matrices as follows:
[ẋ]=[a][x]+[b][u] ve [y]=[c][x]+[d][u]
1: first pair of transfer functions
num: Is the coefficients of the numerator polynom
of the first transfer function
h1(s)
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 3
den: Is the coefficients of the common denominator polynom of
the first transfer function h1(s) and the second transfer function
h2(s)
Also, h3(s) have h4(s) have common denominator. Therefore, by
writing two ‘ss2tf’ we obtain four transfer functions. This is
illustrated below;
[num12, den1]=ss2tf(a,b,c,d,1)
[num34,den2]=ss2tf(a,b,c,d,2]
If we implement this in MATLAB we will get:
num12=
p1 p2 p3
p4 p5 p6

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 4


den1=
q1 q2 q3
num34=
m1 m2 m3
m4 m5 m6
den2=
r1 r2 r3
Here all p, q, m and r are real numbers. Then the transfer functions
will be as given below:
𝒑𝟏 𝒔𝟐 + 𝒑𝟐 𝒔 + 𝒑𝟑 𝒚𝟏 𝒔
𝒉𝟏 𝒔 = 𝟐
=
𝒒𝟏 𝒔 + 𝒒𝟐 𝒔 + 𝒒𝟑 𝒖𝟏 𝒔

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 5


𝒑𝟒 𝒔𝟐 + 𝒑𝟓 𝒔 + 𝒑𝟔 𝒚𝟐 𝒔
𝒉𝟐 𝒔 = 𝟐
=
𝒒𝟏 𝒔 + 𝒒𝟐 𝒔 + 𝒒𝟑 𝒖𝟏 𝒔
𝒑𝟒 𝒔𝟐 + 𝒑𝟓 𝒔 + 𝒑𝟔 𝒚𝟐 𝒔
𝒉𝟐 𝒔 = 𝟐
=
𝒒𝟏 𝒔 + 𝒒𝟐 𝒔 + 𝒒𝟑 𝒖𝟏 𝒔
𝒎𝟒 𝒔𝟐 + 𝒎𝟓 𝒔 + 𝒎𝟔 𝒚𝟐 𝒔
𝒉𝟒 𝒔 = 𝟐
=
𝒓𝟏 𝒔 + 𝒓𝟐 𝒔 + 𝒓𝟑 𝒖𝟏 𝒔
If we apply these to the state-space example given at the
beginning of this section, we obtain:
num12=
0 4 19
0 -1 10
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 6
den1=
1 16 35
num34=
0 0 15
0 3 30
den2=
1 16 35

Therefore, four transfer functions can be obtained as


follows:
𝟒𝒔+𝟏𝟗 −𝒔+𝟏𝟎
𝒉𝟏 𝒔 = 𝒉𝟐 𝒔 =
𝒔𝟐 +𝟏𝟔𝒔+𝟑𝟓 𝒔𝟐 +𝟏𝟔𝒔+𝟑𝟓

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 7


𝟏𝟓 𝟑𝒔+𝟑𝟎
𝒉𝟑 𝒔 = 𝒉𝟒 𝒔 =
𝒔𝟐 +𝟏𝟔𝒔+𝟑𝟓 𝒔𝟐 +𝟏𝟔𝒔+𝟑𝟓

COMPLEX SYSTEM CASE


System given below is a relatively complex
system. We can specify the total system with
a single state-space model and find over-all
transfer functions.

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 8


u2

sis2
sis1 x = ax + bu y2
P1 ( s ) + u3
T (s) = y3
u1
Q1 ( s ) y1 X y = cx + du
y4 -
P2 ( s) u4
H ( s) =
Q2 ( s)
sis3

A typical complex system

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 9


u1 x = Ax + Bu y2

u2
y = Cx + Du y3

Fig. 2: Resulting total state-space model


Since there are two inputs and two outputs there will be four transfer
functions as we have seen above.
To collect system into a single state-space model first we must
describe each system in the total system.
In general, there three types of systems:

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 10


a) State-space model:
Description syntax is as follows:
sisx=ss(a,b,c,d)
Where a, b, c, and d are the state-space matrices. They must
be specified earlier as we will see in the application below.
‘ss’ means state-space model. x at the end of sis shows the
system number. For example, system 1 can be written as:
‘sis1’, i.e.;
sis1=ss(a3,b3,c3,d3)

a) Transfer function system:


Assuming we have a transfer function given as below and it
is transfer function of system 2;

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 11


−𝐬 + 𝟏𝟎
𝒉𝟐 𝒔 = 𝟐
𝐬 + 𝟏𝟔𝐬 + 𝟑𝟓
We can describe this system as:
num2=[0 -1 10] : coefficients matrix of numerator
den2=[1 16 35] : coefficients matrix of denominator
sis2=[num2, den2]

Alternatively, we can write:


sis2=([0 -1 10], [1 16 35])

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 12


c) Zero, Pole, gain system
A zero, pole, gain system is like one given below:

k (n1s + n1 ) 4(2s + 8)
G( s) = = 2
m1s + m2 s + m3 x + 2 x − 24
2

Assuming this system is system 3.


Zeros are the roots of numerator polynom. In this example it is
-8/2=-4=s1
Poles are the roots of denominator polynom. In this example the are
s2=-6 and s3=4.
Gain is the constant multiplier k=4.
Hence we can describe the system 1 as:

sis3=zpk(s1,[s2 s3],k)

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 13


After describing each system in the whole system we need to combine
all systems into one system using MATLAB command ‘append’.
Assuming our system contains all above three types of sub systems
then the over-all single system is described as:
sis=append(sis1,sis2,sis3)
Having described the total system then it is necessary to describe haw
these systems are connected to each other, i.e., which input is coming
from which outputs. For this we can use our own command
‘connections’ and explain this on a real example.

After this it is necessary to describe the inputs terminal that entering


to overall system from outside and outputs going out of the overall
system. If our system is as follows then (3 inputs, two outputs) we can
write:
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 14
u1 Overall y1
u5
u3 system y4
Overall system
inputs=[1 5 3]
outputs=[1 4]
Finally using MATLAB command ‘connect’ total system
together with their interconnection, subsystem types, inputs
and outputs will be established as:

Totsystem=connenct(sis, connections, inputs, outputs)

Now our system is ready for execution in MATLAB. Further


details will be explained on real examples.
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 15
REAL EXAMPLES
EXAMPLE 1
OBTAININING STATE-SPACE MODEL FROM TRANSFER FUNCTION
Let us obtain the state-space model of the following transfer function.
10s + 4
G ( s) = 2
s + 10s + 24
Required MATLAB commands are given below.
num=[0 10 4]; den=[1 10 24];
[A B C D]=tf2ss(num,den)
Here MATLAB command ‘tf2ss’ means transfer function to state-space
conversion.
Running these two statements in MATLAB we get following state-space
matrices:
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 16
A= B= C= D=
-10 -24 1 10 4 0
1 0 0
For more explanation, these results mean following state-space
model (two state variables, single output):

 dx1 
 dt   −10 -24  x1  1 
 =    +   u (t )
 dx2   1 0   x2  0
 dt 
y = 10 x1 + 4 x2 + 0u (t )

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 17


Or,

 x   −10 -24   x1  1 
 x =  1    +   u (t )
   0  x2   0
 x1 
y = 10 4   + 0u (t )
 x2 
Now let us get same transfer function from state-space model.
We type following matrices in MATLAB:
a=[-10 -24; 1 0]; b=[1; 0]; c=[10 4]; d=[0];
[num den]=ss2tf(a,b,c,d)
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 18
And running these two lines program in MATLAB we get:

num =
0 10 4
den =
1 10 24

Which means the following original transfer function:

0s + 10s + 4
2
10 s + 4
G( s) = 2 = 2
s + 10s + 24 s + 10s + 24

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 19


EXAMPLE 2: A MORE COPLEX SYSTEM CASE
A complex system is given below.
a) Find combined single state-space model of the system.
b) Find the 4 transfer functions of the system.

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 20


Values of the matrices a1, b1, c1 and d1 are given below.
Solution:
MATLAB file for solution of part a will be as follows:

a1=[-3.2 6.4; -1.7 4.3];


b1=[-1.2 3.5; -0.6 -1.5];
c1=[2 3.5; -7.1 12.8];
d1=[-0.46 -0.35; -0.71 -0.44];
sis1=tf([0 8],[2 6],'inputname',‘u1');
sis2=ss(a1,b1,c1,d1,'inputname',{‘u2',‘u3'},'outputname',
{'y1','y2'});
sis3=zpk(-2,-5,3) % zero pole gain k
sis=append(sis1,sis2,sis3);

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 21


connections=[1 0 0
200
3 3 -4
4 2 0];
inputs=[1 2];
outputs=[1 2];
TOTALSYS=connect(sis, connections, inputs, outputs)

Running above program in MATLAB we obtain the


following results (four state variables and two outputs
system):

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 22


c=
x1 x2 x3 x4
y1 2.187 25.3 -38.5 2.842
y2 2.75 22.19 -40 3.572
3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 23
d=
x1 x2
y2 0 1.87
y3 0 2.219
Continuous-time model.

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

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 24


In order to obtain transfer functions a, b, c, and d sate-space parameter
obtained from last run must be carried out into the program as new state-
space matrices as:
A, B, C and D.
Then it is sufficient to execute following 4 lines program to get following 4
transfer functions:
Fort this we must use symbolic mat for s (Laplace operator)
Transfer functions will be as follows:
1) from u1 to y2
2) from u1 to y3
3) from u2 to y2
4) from u2 to y3

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 25


First two lines of the following program will give transfer functions 1 and
2 described above.
Last two lines of the following program will give transfer functions 3 and
4 described above.

[pay1,payda1]=ss2tf(A,B,C,D,1);
printsys(pay1,payda1,'s')

[pay2,payda2]=ss2tf(A,B,C,D,2);
printsys(pay2,payda2,'s')

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 26


Transfer function from U1 to y2

4.56 s^3 + 69.86 s^2 + 999.38 s + 5315.07


-----------------------------------------------------------------------
s^4 + 407.53 s^3 + 1701.77 s^2 + 802.2 s - 1987.12

Transfer function from U1 to y3:


5.5 s^3 + 572.35 s^2 + 2249.39 s - 2369.44
---------------------------------------------------------------------------
s^4 + 407.53 s^3 + 1701.77 s^2 + 802.2 s - 1987.12

Transfer function from U2 to y2

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 27


1.87 s^4 - 197.39 s^3 - 2079.65 s^2 - 6633.2 s - 6663.69
----------------------------------------------------------------------------------
s^4 + 407.53 s^3 + 1701.77 s^2 + 802.2 s - 1987.12

3.11.2020 Prof. Dr. M. Akbaba State-stae and transfer function 28

You might also like