2 Simulation and Analysis using a MATLAB Mfle
This section introduces several MATLAB commands that are useful for studying ODEs and their solutions. The
MATLAB command
roots
determines the roots of the characteristic equation
Q
(
λ
)=
λ
n
+
a
n

1
λ
n

1
+
···
+
a
1
λ
+
a
o
=0
.
For example, if
Q
(
D
D
3
+4
D
2
+
D

3
,
enter
>> Q
=[1
,
4
,
1
,

3]; roots(
Q
)
and MATLAB will return the roots of
Q
(
λ
) = 0. Note that the polynomial
Q
(
D
) is entered as a row vector in
MATLAB, where the ±rst element is the coeﬃcient associated with
D
3
.
The command
step
determines the unitstep response of a system. For example, suppose we want to determine
the unitstep response of a secondorder system described by the ODE
d
2
y
dt
2
dy
dt
+ 100
y
(
t
) = 200
f
(
t
)
.
First represent the ODE as
Q
(
D
)
y
(
t
P
(
D
)
f
(
t
)
,
where
Q
(
D
D
2
D
+ 100
P
(
D
)=2
0
0
.
Represent these polynomials in MATLAB as row vectors
>> Q
=[
1
,
4
,
100];
>> P
=
[200];
The MATLAB command
>>
step(
P,Q
)
generates a plot of the unitstep response over a time interval determined by MATLAB. To generate the unitstep
response at 200 points over a speci±ed time interval, say 0
≤
t
≤
5, use the commands
>>
Q
,
4
,
100];
>>
P
= [200];
>>
t
= linspace(0
,
5
,
200);
>>
step(
P,Q,t
)
You can also save the response to a vector
y
using
>>
Q
,
4
,
100];
>>
P
= [200];
>>
t
= linspace(0
,
5
,
200);
>>
y
= step(
);
MATLAB provides a command,
lsim
, for determining the zerostate response of a LTI system to an arbitrary
input. As an example, the zerostate response of the system
˙
y
+
y
(
t
)=6
f
(
t