Graphics Programs Reference
In-Depth Information
u
(
t
), and at the
j
th time, the car positions are stored in the
j
throw of the
matrix
carpositions.signals.values
. Try the program!
We should mention here one fine point needed to create a realistic movie.
Namely, we need the values of
tout
to be equally spaced — otherwise the
cars will appear to be moving faster when the time steps are large and will
appear to be moving slower when the time steps are small. In its
default
mode of operation, SIMULINK uses a variable-step differential equation
solver based on MATLAB's command
ode45
, and so the entries of
tout
will
not
be equally spaced. To fix this, open the
Simulation Parameters...
dialog box using the
Edit
menu in the model window, choose the
Solver
tab,
and change the
Output options
box to read:
Produce specified output
only
, chosen to be something such as [0:0.5:20]. Then the model will output
the car positions only at multiples of
t
=
0
.
5, and the MATLAB program
above will produce a 41-frame movie.
Search WWH ::
Custom Search