User`s guide

Model Execution
6-19
MdlTerminate(void) MdlTerminate contains any block shutdown code.
MdlTerminate is called by the run-time interface, as part of the termination
of the real-time program.
The contents of the above functions are directly related to the blocks in your
model. A Simulink block can be generalized to the following set of equations:
Output, y, is a function of continuous state, x
c
, discrete state, x
d
,andinput,u.
Each block writes its specific equation in the appropriate section of
MdlOutput.
The discrete states, x
d
, are a function of the current state and input. Each block
that has a discrete state updates its state in
MdlUpdate.
The derivatives, x, are a function of the current input. Each block that has
continuous states provides its derivatives to the solver (e.g.,
ode5)in
MdlDerivatives. The derivatives are used by the solver to integrate the
continuous state to produce the next value.
The output, y, is generally written to the block I/O structure. Root-level
Outport blocks write to the external outputs structure. The continuous and
discrete states are stored in the states structure. The input, u, can originate
from another block’s output, which is located in the block I/O structure, an
external input (located in the external inputs structure), or a state. These
structures are defined in the
model.h file that the Real-Time Workshop
generates.
yf
0
tx,
c
x
d
u,,()=
x
d1+
f
u
tx,
d
u,()=
x
·
f
d
tx
c
u,,()=