Professional Documents
Culture Documents
State Variable Models
State Variable Models
State Variable Models
Objectives:
The objectives of this application are to:
1. Obtain the state space model from the differential equations or transfer
function.
2. Convert between transfer function and state space models.
3. Determine the state transition matrix Φ(𝑠).
Where:
𝑥 = state vector, 𝑥̇ = derivative of state vector with respect to time.
𝑦 = output vector, 𝑢 = input or control vector.
A = system matrix, B = input matrix, C =output matrix, D= feedforward
matrix.
A block diagram representation of state and output Equations is shown
in Figure 1.1.
Figure 1.1: Block diagram of the control system represented in state space.
Example 1.1: A single loop control system is shown in Figure 1.2. The
closed loop transfer function of the system is:
𝑌(𝑠) 2𝑠 2 + 8𝑠 + 6
𝑇(𝑠) = =
𝑅(𝑠) 𝑠 3 + 8𝑠 2 + 16𝑠 + 6
Where 𝑦 is the output and 𝑢 is the input to the system (𝑢(𝑡) = 1). Obtain
state space representation of the system.
Solution:
>> % Firstly, convert the differential equation to transfer function%
>> Y=laplace(dsolve('D3y+6*D2y+11*Dy+6*y=20','y(0)=0,Dy(0)=0,D2y(0)=0'));
>> pretty(simplify(Y))
20
------------------------------ % Y(s) = T(s)*U(s), U(s) = 1/s %
s (s + 1) (s + 2) (s + 3)
>> % The transfer function T(s)=20/(s+1)(s+2)(s+3) %
>> num=20;
>> den=conv([1 1],conv([1 2],[1 3]));
>> [a,b,c,d]=tf2ss(num,den);
>> % To obtain the state space model in the phase variable canonical form %
>> A=flipud(fliplr(a))
A=
0 1 0
0 0 1
-6 -11 -6
>> B=flipud(b)
B=
0
0
1
>> C=fliplr(c)
C=
20 0 0
Example 1.3: The two tank system shown in Figure 1.3(a) is controlled by
a motor adjusting the input valve and ultimately varying the output flow
rate. The system has the block diagram shown in Figure 1.3(b). Use
MATLAB to:
1. Obtain the matrix differential equation for the phase variable form.
2. Plot the output response of the system when the input signal is unit step.
Figure 1.3: A two tank system with the motor current controlling the output flow rate.
(a) Physical diagram. (b) Block diagram.
Solution:
>> % Firstly, determine the transfer function: G(s)= Q o(s)/I(s)%
>> s=tf('s');
>> G1=10/(s+5);
>> G2=3/(s+2);
>> G3=1/(s+3);
>> G=series(G1,series(G2,G3))
Transfer function:
30
--------------------------------
s^3 + 10 s^2 + 31 s + 30
>> % To obtain the state space model in the phase variable canonical form %
>> A=flipud(fliplr(a))
A=
0 1 0
0 0 1
-30 -31 -10
>> B=flipud(b)
B=
0
0
1
>> C=fliplr(c)
C=
30 0 0
>> % To plot the output response of the system for the unit step input %
>> t=0:0.01:10;
>> r=heaviside(t);
>> lsim(a,b,c,d,r,t)
>> title('Step Response of the Two Tank System')
>> xlabel('Time')
>> ylabel('Output Flow Rate')
>> gtext('Input')
>> gtext('Output')
Input
1
Output
0.8
Output Flow Rate
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10
Time (sec)
Figure 1.4: Output response of the two tank system for Example 1.3.
Example 1.4: A single input single output system has the matrix equation:
0 1 0
𝑥̇ = [ ]𝑥 + [ ]𝑢
−3 −4 1
and
𝑦 = [10 0]𝑥
Using MATLAB:
1. Determine the state transition matrix Φ(𝑠).
2. Determine the transfer function 𝐺(𝑠) = 𝑌(𝑠)/𝑈(𝑠).
Solution:
Transfer function:
10
------------------
s^2 + 4 s + 3
Figure 1.5: Simulation the system of Example 1.5 using MATLAB Simulink.
1.6 Output
1.4
1.2
1
Output
Input
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10
Time(sec)
Figure 1.6: Unit step response of the system for Example 1.5.
--------------------------------------------------------------------------------------------
Homework 1.1: Consider the spring - mass - damper system as shown in
Figure 1.7. The external force 𝑟(𝑡) is the input to the system (unit step),
and the displacement 𝑦(𝑡) of the mass is the output where 𝑀 = 1.5 kg,
𝑘 = 100 N/m, and 𝑏 = 20 N. s/m.
Do the following:
1. Obtain the differential equation of the system. Assume the initial
conditions equals to zero.
2. Use MATLAB to obtain state space representation of the system in the
phase variable canonical form.
--------------------------------------------------------------------------------------------
Homework 1.2: A system has a block diagram as shown in Figure 1.8. Do
the following using MATLAB:
1. Determine the overall transfer function 𝑌(𝑠)/𝑅(𝑠).
2. Determine the state variable differential equation in a matrix form.
3. Obtain the state transition matrix Φ(𝑠) and Φ(𝑡).
𝑦 = [1 0 0]𝑥1 (1)
and