User`s guide
6 Program Architecture
6-30
Integration of Continuous States
The real-time program calculates the next values for the continuous states
based on the derivative vector, dx/dt, for the current values of the inputs and
the state vector.
These derivatives are then used to calculate the next value of the states using
a state-update equation. This is the state-update equation for the first order
Euler method (
ode1).
where h is the step size of the simulation, x represents the state vector, and dx/
dt is the vector of derivatives. Other algorithms may make several calls to the
output and derivative routines to produce more accurate estimates.
Note, however, that real-time programs use a fixed-step size since it is
necessary to guarantee the completion of all tasks within a given amount of
time. This means that, while you should use higher order integration methods
for models with widely varying dynamics, the higher order methods require
additional computation time. In turn, the additional computation time may
force you to use a larger step size, which can diminish the accuracy increase
initially sought from the higher order integration method.
Generally, the stiffer the equations, (i.e., the more dynamics in the system with
widely varying time constants), the higher the order of the method that you
must use.
In practice, the simulation of very stiff equations is impractical for real-time
purposes except at very low sample rates. You should test fixed-step size
integration in Simulink to check stability and accuracy before implementing
the model for use in real-time programs.
For linear systems, it is more practical to convert the model that you are
simulating to a discrete time version, for instance, using the
c2d function in the
Control System Toolbox.
xx
dx
dt
-------
h+=