Systems of Differential Equations
State Variable Equation Synthesis
A system may be described by a differential equation, a transfer function or by a
system of differential equations. Consider the differential equation
d 3 y (t ) d 2 y (t ) dy(t ) dx(t )
2 y (t ) 2 x(t ).
dt dt dt dt
The corresponding transfer function is
Y ( s) s2
H ( s) 3 .
X ( s) s 2s 2 2s 1
The corresponding state-variable equations (in general form) are
w Aw cx.
We can determine the values of A,c and b using tf2ss (transfer function to
>> [A,c,b] = tf2ss([1 2], [1 2 2 1]);
Verify that the matrices created by this MATLAB command are the same at those
created manually or analytically using the state-space creation technique
discussed in the lecture. MATLAB arranges the order of the rows of the state-
variable equations differently than in the lecture. The state-variable equations
can also be converted back to a transfer function using
>> [num, den] = ss2tf(A, c, b, 0);
(You need a zero in the non-existent ‘D’ argument.) The answer you get is
should correspond to the original transfer function. You can also manually
calculate the answer using
H ( s ) bsI A c.
You can also use MATLAB to do this formulation:
>> syms s;
Using Laplace transforms and the methods discussed in Project #2, find the
solution to the differential equation if x(t) = u(t).
Numerical Solutions to State Variable Equations
The MATLAB function ode45( ) can be used to numerically solve simultaneous
differential equations. In Project #1, this function was used to solve a first-order
differential equation. The general form of the function is
>> [t y] = ode45(‘de’, <time range>, <initial conditions>);
The de.m function specified the differential equation. Suppose that we had a
matrix differential equation,
y1 0 0 1 y1 0
y 2 0 2 0 y 2 0 u (t ).
y 3 3 0 0 y3 1
The de.m file would look like this:
function ydot = de(t,y)
ydot = zeros(size(y));
ydot(1) = y(3);
ydot(2) = 2*y(2);
ydot(3) = 3*y(1)+1;
The <time range> is a two-element array for begin and end times for the
numerical simulation, e.g., [0 1] would correspond to the time from zero to one.
The <initial conditions> is an array corresponding to y1(0), y2(0), etc., e.g., [0 0
0] would be for a system initially at rest. Find the solution to the differential
equation in the previous section numerically if the input x(t) is a step function u(t).
Let the initial conditions be y(0) = 0, y’(0) = 0, y’’(0) = 0. By plotting, compare the
analytic solution (derived in the first section) to the numeric solution.