LINEAR CONTROL SYSTEMS LAB
Name __________________________________
Regd. No. ___________________________
Experiment # 5 State Variable Models
Objectives
1. To learn how to covert the transfer function of a system into state variable
representation and vice versa.
2. To learn how to simulate a system expressed in state variable form.
New MATLAB commands to learn in this experiment
MATLAB Command
tf2ss
ss2tf
lsim
Description
TF2SS Transfer function to state-space conversion.
[A,B,C,D] = TF2SS(NUM,DEN) calculates the state-space representation:
SS2TF State-space to transfer function conversion.
[NUM,DEN] = SS2TF(A,B,C,D,iu) calculates the transfer function:
LSIM(SYS,U,T) plots the time response of the LTI model SYS to the input
signal described by U and T. The time vector T consists of regularly spaced
time samples and U is a matrix with as many columns as inputs and whose i-th
row specifies the input value at time T(i).
Procedure
Section-1
Conversion between transfer function and state space models:
a. Transfer Function into state space models
Transfer functions represented by numerator and denominator or an LTI object can be
converted to state space. For numerator and denominator representation, the conversion can
be implemented using [A, B, C, D] = tf2ss (num,den)
C(s)/R(s) = 24/s3+9s2+26s+24
Experiment 5
State Variable Models
Page 1 of 6
LINEAR CONTROL SYSTEMS LAB
Name __________________________________
Regd. No. ___________________________
Write Matlab commands to convert the above transfer function into state space.
>> N= [24];
>> D= [1 9 26 24];
>> [A B C D] =tf2ss(N, D)
A=
B=
C=
D=
b. State space into transfer function models
A system expressed in state-space can be converted to transfer function. Following
statement is used to convert the state-space representation of a system discussed before
into transfer function.
[N,D] = ss2tf(A, B, C, D);
Write the Verify that the N and D.
N(s) of the transfer function =
D(s) of the transfer function =
N=
D=
Experiment 5
State Variable Models
Page 2 of 6
LINEAR CONTROL SYSTEMS LAB
Name __________________________________
Regd. No. ___________________________
Section-2
Time response of a system represented in state-space can be computed by using
function lsim. For this purpose, all four matrices (A, B, C, D) of a state-space model
along with initial conditions, a time vector (range of time) and an input vector are
required. RLC circuit shown below. In this model, state variables x1 and x2 are the
capacitor voltage and inductor current respectively and the output y is the resistor
voltage.
L
u(t)
+
vc
_
+
vo
_
An RLC circuit.
r = 3; l = 1; c = 0.5;
A = [0 1/c; 1/l r/l];
B = [1/c; 0];
C = [0 r];
D = [0];
x0 = [1 1];
% initial conditions.
t = [0:0.01:5]; % time range is 0 to 5 sec with an increment of 0.01 sec.
u = 0*t ;
% zero input.
[y, x] = lsim(A, B, C, D, u, t, x0);
lsim function returns two parameters, output matrix y having one column and state
variable matrix x having two columns. Use size(y) and size(x) to see the number of
rows and columns in y and x.
Note: Number of rows in x and a y matrix is equal to the number of data points in
time vector t.
Use following commands to observe the time response of the system defined in
previous step.
subplot(3, 1, 1);
% divide the figure window into 3 rows and 1 column.
plot(t, x(:,1));
% plot the 1st state variable, column 1 of matrix x.
xlabel('time'); ylabel('x1');
subplot(3, 1, 2);
plot(t, x(:,2));
% plot the 2nd state variable, column 1 of matrix x.
Experiment 5
State Variable Models
Page 3 of 6
LINEAR CONTROL SYSTEMS LAB
Name __________________________________
Regd. No. ___________________________
xlabel('time'); ylabel('x2');
subplot(3, 1, 3);
plot(t, y));
% plot the output state variable.
xlabel('time'); ylabel('output (y)');
Sketch the state variables x1, x2 and the output y. Label all the curves appropriately.
State variable x1 Vs time.
State variable x2 Vs time.
Output variable y Vs time.
Experiment 5
State Variable Models
Page 4 of 6
LINEAR CONTROL SYSTEMS LAB
Name __________________________________
Regd. No. ___________________________
Change the system parameters R, L and C in the circuit shown above to generate four
types of time responses as shown in the following table. Also, show the values of R, L
and C and position of poles for each type of response.
Case
1
2
3
4
Type of Response
Overdamped
Critically Damped
Underdamped
Oscillatory
System Parameters
R=
L=
C=
R=
L=
C=
R=
L=
C=
R=
L=
C=
Position of Poles
Sketch the output y (resistor voltage) for all four cases.
Case-1: Overdamped.
Case-2: Critically damped.
Case-2: Underdamped.
Experiment 5
State Variable Models
Page 5 of 6
LINEAR CONTROL SYSTEMS LAB
Name __________________________________
Regd. No. ___________________________
Case-4: Oscillatory.
Write your comments on this experiment.
Checked by:
Experiment 5
Date:
State Variable Models
Page 6 of 6