Nikhilcslab4
Nikhilcslab4
Problem Statement:
Q1. Convert the given transfer function into a state space model
Y (s ) 2
s +7 s+2
= 3
U ( s ) s +26 s2 +9 s+24
x=
'
[−31 −31 ] x +[ 12] u
y= [ 2 3 ] x+1 u
Y ( s ) ( Y ( s )∗X 1 ( s ) )
Let =
U ( s ) X 1 ( s )∗U ( s )
Y (s)
On comparing numerator part of transfer function with ,
X1 (s )
Y (s)
We get =s 2+ 7 s+ 2
X1 (s )
2
Y ( s )=s X 1 ( s ) +7 s X 1 ( s )+ 2 X 1 ( s )
'' '
y=x 1 + 7 x 1=2 x 1 ...............................(1)
X1 (s )
On comparing denominator part of transfer function with, ,
U (s )
We get,
X1 (s ) 1
= 3
U ( s ) s +26 s +9 s+24
2
3 2
U ( s )=s X 1 ( s ) +26 s X 1 ( s )+ 9 s X 1 ( s )+24 X 1 ( s )
'' '' '
u=x1 + 26 x1 +9 x 1+24 ...................................(2)
We will use the 'ss2tf' function and the transfer function formula, which takes the state space
matrices (A, B, C, and D) as inputs and provides the corresponding transfer function
coefficients.
Mathematical Modelling:
From the phase variable relationship, we get :
'
x 1=x 2 ....................(3)
'' '
x 1 =x 2=x 3 ❑
.....................(4)
'' ' '' '
x 1 =x 2 =x3 .....................(5)
We get,
y=x 3 +7 x 2 +2 x 1
y=2 x 1 +7 x2 + x 3 ...................(6)
Similarly Using eqn (3), eqn (4) and eqn (5) in eqn (2).
We get:
'
u=x3 +26 x 3 +9 x 2+ 24 x 1
'
x 3=−24 x 1−9 x 2−26 x 3 +u ....................(7)
Implementation and Verification of Model in MATLAB/Simulink:
In1
1 1 1
s s s
Gain
Integrator Integrator1 Integrator2
Subtract
1
Gain2 Out1
Add
Gain1
Gain3
Gain4
Fig 1: Mathematical model representing the state space model of the system
Matlab codes:
Formula Method
clc;
close all;
clear;
num=[1 7 2]
den=[1 26 9 24]
[A1 B1 C1 D1]=tf2ss(num,den)
p=[0 0 1; 0 1 0; 1 0 0]
A=inv(p)*A1*p
B=inv(p)*B1
C=C1*p
D=D1
Simulink Method
A =
0 1 0
0 0 1
-24 -9 -26
B =
0
0
1
C =
2 7 1
D =
num =
1 7 2
den =
1 26 9 24
A1 =
-26 -9 -24
1 0 0
0 1 0
B1 =
1
0
0
C1 =
1 7 2
D1 =
p =
0 0 1
0 1 0
1 0 0
A =
0 1 0
0 0 1
-24 -9 -26
B =
0
0
1
C =
2 7 1
D =
Result of Q2.
T =
den =
1 6 8
T =
s^2 + 14 s + 39
---------------
s^2 + 6 s + 8
Conclusion
In this lab we learnt to convert transfer function to state space model and vice-versa by using
Simulink model and MATLAB. State-space models are more detailed and versatile, making
them suitable for complex systems and advanced control techniques. On the other hand,
transfer functions provide a simpler and more intuitive representation for frequency domain
analysis, making them useful for basic control system design and analysis. The conversion
between these two representations is a valuable tool in control engineering, allowing
engineers
to choose the most appropriate model for their specific needs.