You are on page 1of 15

University of Engineering and Technology, Lahore Fall 2016

STATE SPACE REPRESENTATION


Name : Ali Hamza Date : 12/1/2016
Regd-No :2014-MC-06

OBJECTIVES:
 Understand state-space representation of systems.
 Representing physical systems in State Space using MATLAB.
 Simulating the response of a system to standard inputs with State Space
Models
SUGGESTED READING:
 Chapter 5: “State Space approach to Modeling Dynamic Systems”, from book “System
Dynamics”, by Ogata.
 Lecture Notes on State Space by Dr. Salman, MCE Dept., UET Lahore
 State Variable Description of LTI Systems
http://web.mit.edu/16.unified/www/FALL/signalssystems/Lecture11_12.pdf
 Introduction to State Space Modeling
https://www.youtube.com/watch?v=X3TOZLJCWiY

Please go through the suggested reading before you come to lab.

SOFTWARE REQUIRED
 MATLAB

Note: Vectors and Matrices are denoted in bolded fonts


---------------------------------------------------------------------------------------------------------------------
Introduction
A typical Single-Input-Single-Output (SISO) continuous-time (or discrete-time)
LTI system is usually modeled by an n-th order differential (or difference)
equations. Besides, a state space representation is a mathematical model as set of
first-order differential (or difference) equations. This set contains n first order
differential (or difference) equations in terms of inputs, outputs and state variables.
To abstract from the number of inputs, outputs and states, the variables are
expressed as vectors and the differential and algebraic equations are written in
matrix form. The state space representation (also known as the "time-domain
approach") provides a convenient and compact way to model and analyze systems
with multiple inputs and outputs.

MCT-304: Modeling and Simulation 1


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

In this laboratory experiment, you will experience MATLAB commands for


implementing a state-space model in continuous-time LTI
SISO system including:
a) Creating LTI Models
b) Switching Model Representation
c) Connecting Models
d) Analyzing LTI Models

These commands can be extended in Multi-Input-Multi-Output (MIMO) system.


Same approach for discrete-time system is also applicable as discrete-time system
is counterpart of continuous-time system.
Consider an n-th order SISO continuous-time LTI system has a Laplace transform,

In general, state-space representation (model) in vector-matrix form is given by the


equations:
ẋ ( t )= A x ( t ) + B u (t )∧ y ( t )=C x ( t ) + D u(t)

where
u(t) is input signal, y(t) is output signal,
x(t) is n x 1 state vector,
A is n x n matrix, B is n x 1 matrix, C is 1 x n matrix, D is scalar

Fig.1: Block diagram of the linear continuous time system represented in state space

MCT-304: Modeling and Simulation 2


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

Transient-Response Analysis in State Space form using


MATLAB

If the system is represented in the state space form (i.e broken down to matrices A,
B, C, D) a state-space model object can be created in MATLAB using the ‘ss’
command.

We first define the system with


sys = ss(A,B,C,D)

For a unit-step input, the MATLAB command


step(sys) or step(A,B,C,D)

Example 1:
For a spring-mass-damper system represented by the following state equations,
create a state-space model in MATLAB and find its step response;
m= 10kg, k = 50N/m, b =20Ns/m

Solution:
Create the state matrix, and the output equation matrix.:

m=20;
k=50;
b=20;
A= [0 1;-k/m -b/m];
B= [0; 1/m];
C= [1 0];

MCT-304: Modeling and Simulation 3


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016
D=0;
sys = ss(A,B,C,D)
step(sys)

Result:

Step Response
0.03

0.025

0.02
Amplitude

0.015

0.01

0.005

0
0 2 4 6 8 10 12
Time (seconds)

MCT-304: Modeling and Simulation 4


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

a) Extraction of the coefficients


The coefficients of matrix from object form can be extracted by the using
MATLAB ‘ssdata’ commands.
Example 2:
Extract the coefficients of the matrix from the object form that obtained in
Example 1
Solution:
Use the ssdata command to extract coefficients from a system model.

MCT-304: Modeling and Simulation 5


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

b) Switching Model representation

You can convert models from/to state-space model to/from other model (transfer
function model or zero-pole-gain model) using MATLAB commands.
The model type conversion paths and MATLAB commands are summarized in the
diagram below.

Example 3:
A system is represented by its transfer function as given below:
5 s+25
H (s)= 2
s +5 s+ 25

Convert the transfer-function to a state-space model.


Solution:
You can convert transfer function model to state-space model by typing following
commands in Command Window
num = [5 25];
den = [1 5 25];
[A,B,C,D] = tf2ss(num,den)

MCT-304: Modeling and Simulation 6


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

Result:

Example 4:
You can convert state-space model that obtained in Example 1 to transfer function
model by typing following commands in Command Window
m=20;
k=50;
b=20;
A= [0 1;-k/m -b/m];
B= [0; 1/m];
C= [1 0];
D=0;
[num,den] = ss2tf(A,B,C,D)
Result:

MCT-304: Modeling and Simulation 7


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

Example 5:
You can convert state-space model that obtained in Example 1 to zero-pole-gain
model by typing following commands in Command Window
m=20;
k=50;
b=20;
A= [0 1;-k/m -b/m];
B= [0; 1/m];
C= [1 0];
D=0;
[z,p,k] = ss2zp(A,B,C,D)
Result:

c) Analyzing LTI Models


In this part, you will examine several commands in the analyzing of the LTI
system. These commands compute the poles and zeroes of the system, and mark
them onto s-plane. In addition, an impulse and step response of the system will
also be evaluated. In this section, the object form of state-space model will be
discussed.

MCT-304: Modeling and Simulation 8


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016
1) Computing the zeros, poles and gain from the state-space model with the
commands:

2) The plot of the poles and zeroes onto the s-plane can be obtained by using
MATLAB pzmap command from the object form. There is no specified
MATLAB command for obtaining the plot from the matrix form.

3) The unit impulse and step response can be determined by using the
MATLAB impulse and step commands respectively.

4) The zero-input response of LTI system with non-zero initial condition can be
determined by using the MATLAB initial command.

5) The time response of LTI models to arbitrary inputs can be determined by


using the MATLAB lsim command. The response of LTI system with non-
zero initial condition can also be determined.

Example 6:
With the following system (H(s)) from example 3,
5 s+25
H (s)= 2
s +5 s+ 25
Determine, after representing the system in state space;
a) a pole-zero map
b) impulse response
c) step response

Solution:
You can convert transfer function model to state-space model by typing following
commands in Command Window
num = [5 25];
den = [1 5 25];
[A,B,C,D] = tf2ss(num,den);
sys1 = ss(A,B,C,D);
pzmap(sys1); % Plot appropriately on new
impulse(sys1); % figures by yourself
step(sys1);

MCT-304: Modeling and Simulation 9


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

Pole-Zero Map
Result: 5

4
System: sys1
Pole : -2.5 + 4.33i
3
System: sys1 Damping: 0.5
Imaginary Axis (seconds -1)

Zero : -5 Overshoot (%): 16.3


2
Damping: 1 Frequency (rad/s): 5
1 Overshoot (%): 0
Frequency (rad/s): 5
0

-1
System: sys1
-2
Pole : -2.5 - 4.33i
Damping: 0.5
-3
Overshoot (%): 16.3
Frequency (rad/s): 5
-4

-5
-5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0
Real Axis (seconds -1)

Impulse Response
5

3
Amplitude

-1
0 0.5 1 1.5 2 2.5
Time (seconds)
Step Response
1.4

1.2

1
Amplitude

0.8

0.6

MCT-304:
0.4
Modeling and Simulation 10
Department of Mechatronics
0.2 and Control Engineering, U.E.T Lahore
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (seconds)
University of Engineering and Technology, Lahore Fall 2016

Lab Assignment: Section 1: Creating state-space models


TASK 1:
Create the state-space model in MATLAB for the following systems. Describe the
systems by their system matrices, A, B, C, D.
2
G 1( s) =
(s +1)( s+ 2)

1
G 2( s) = 2
s + s+1
Solution:
Code:

Output:

MCT-304: Modeling and Simulation 11


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

Section 2: Analysis of LTI systems using state-space models


TASK 2:
Suppose an LTI system is represented by the following differential equation.

4 ẍ+ 6 ẋ +10 x=u(t )


Assuming the system has zero initial conditions,
a) Express the state space model of the system
b) Determine the poles and zeros of the system
c) Plot the step and impulse response of the system
d) Plot the response of the system to an input u(t) = 2sin10t (from 0 to 10
seconds)

MCT-304: Modeling and Simulation 12


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

TASK 3: Problem A-5-7


'Two masses ml and m2 are connected by a spring with spring constant k, as shown
in the figure. Assuming no friction, derive a state-space representation of the
system, which is at rest for t < 0. The displacements y1 and y2 are the outputs of
the system and are measured from their rest positions relative to the ground.
Assuming that ml = 40 kg, m2 = 100 kg, k = 40 N/m, and f is a step force input
of magnitude of 10 N, obtain the response curves yl (t) versus t and y2(t) versus t
with MATLAB.
Also, obtain the relative motion between ml and m2. Define y2 - yl = x and plot the
curve x(t) versus t. Assume that we are interested in the period 0 ≤ t ≤ 20.

MCT-304: Modeling and Simulation 13


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

TASK 4: RLC Circuits

Consider the RLC circuit given above.


a) Considering the voltages across resistor R2, and capacitor C1 as outputs,
create a state space representation of the system.
b) Using MATLAB, create a transfer function from the state space, and also
show the pole-zero map.
c) Using MATLAB plot the step response of the system.
d) Plot the response of the system to a square wave input of 20Hz frequency,
and duty cycle of 50%, for a time 0 ≤ t ≤ 0.2 s

MCT-304: Modeling and Simulation 14


Department of Mechatronics and Control Engineering, U.E.T Lahore
University of Engineering and Technology, Lahore Fall 2016

MCT-304: Modeling and Simulation 15


Department of Mechatronics and Control Engineering, U.E.T Lahore

You might also like