Alina Shah Dcs Lab 6
Alina Shah Dcs Lab 6
State Space
Representation
Y ( t )=CX ( t ) + DU (t)
[ ] [ ][ ] [ ]
0
x˙1 = 0 1 x 1 +
1 u
x˙2 0 0 x2
m
y=¿
Solution
Using Laplace
sX ( s ) − X ( 0 )= AX ( s ) +BU (s)
[ sI − A ] X ( s ) =X ( 0 ) + BU (s )
−1 −1
X ( s ) =[ sI − A ] X ( 0 ) + [ sI − A ] BU (s)
A=n * n state matrix
B=n *m input or control matrix
C=l *n output matrix
D=l *m direct transmission matrix
MATLAB has a special state space representation obtained with the command ss.However,
some state commands only operate on one or more of the matrices (A, B, C, D).
To enter a matrix
A=
[ −51 14 ]
Use the command
A=[1 ,1 ; −5 , − 4]
If B, C, and D are similarly entered, we obtain the state space quadruple p with
the command
p=ss( A , B , C , D)
We can also specify names for the input (torque, say) and output (position) using
the set command
[ ] [ ][ ] [ ]
ẋ 1 ( t ) 01 0 x1 0
ẋ 2 ( t ) = 0 01 x2 + 0 U (t)
ẋ3 ( t ) 0− 10 −11 x 3 10
g=tf (ss ( A . B ,C , D ))
To create a transfer function matrix, we define its numerator and denominator then use the
command tf as in the case of a scalar transfer function. The numerator is created as a cell ar-
ray with each entry including a vector of coefficient from the corresponding numerator poly-
nomial. The denominator is created similarly using denominator polynomials. For example,
to create the transfer function we obtained in our example.
X ( t f )=e A ( t −t ) X ( t 0 )+∫ e A (t − τ ) BU ( τ ) dτ
f 0 f
t0
Now assuming the initial and final time correspond to t 0=kT and t f =( k +1 ) T
( k +1) T
AT
X ( k +1 )=e X ( k )+ ∫ e A ( (k +1) T − τ ) BU ( τ ) dτ
kT
pd=c 2 d ( p ,.1)
Ad=expm( A ∗ 0.1)
Bd=A ( Ad −eye ( ¿( A ¿) ) ) ∗ B
Example:
The RLC resonance circuit of figure below with capacitor voltage as output has the state
space model
[ ]
0 1
ẋ=
−
1
LC L
[]
R x+ 0 u
1
Assuming normalized component values such that R/L=2, 1/LC=10 Obtain the discrete stat
and input matrix for the series resonances circuit with a DAC and ADC and a sampling
period T. Evaluate the matrices for T = 0.05 s and check your answer with MATLAB.
Solution :
Task 2:
[ ] [ ][ ] [ ]
ẋ 1 ( t ) 01 0 x1 0
ẋ 2 ( t ) = 0 01 x2 + 0 U (t)
ẋ3 ( t ) 0− 10 −11 x 3 10
The expressions for obtaining z-domain and s-domain transfer functions differ only in that
Z in the former is replaced by s in the latter. The same MATLAB command is used to obtain
s-domain and z-domain transfer functions. The transfer function for the matrices (Ad, Bd, C,
D) is obtained with the commands.
P = ss(Ad, Bd, C, D,T)
Where T is the sampling period. The poles and zeros of a transfer function are obtained with
the command.
gd = tf(p)
zpk(gd)
Comments:
In conclusion the first MATLAB code smoothly transforms a continuous-time system into its discrete-
time counterpart using the c2d function, where we specify the sampling period. It's like converting a
movie from regular speed to slow motion. The code then extracts the necessary matrices for the dis-
crete-time system from the result. Adding comments would help understand each part better.
The second MATLAB code, using the ss command, translates the discrete-time system matrices into
a transfer function, showing how the system behaves in a different representation. Think of it as
converting a recipe into a finished dish. By examining the poles and zeros with the zpk function, we
can understand key characteristics like stability and frequency response. Adding comments and in-
terpretations of the poles and zeros would provide deeper insight into the system's behaviour.