User`s guide

Examples of C MEX-File S-Function Blocks
3-61
Example - Discrete State S-Function
The matlabroot/simulink/src/dsfunc.c example shows how to model a
discretesystemin a C MEX S-function.Discretesystems can bemodeled bythe
following set of equations:
dsfunc.c implements a discrete state-space equation. The output portion is
placed in
mdlOutputs and the update portion in mdlUpdate. To visualize how
the simulation works, refer to the flowchart on page 3-16. The output equation
above corresponds to the
mdlOutputs in the major time step. The update
equation above corresponds to the
mdlUpdate in the major time step. If your
model does not contain continuous elements, the integration phase is skipped
and time is moved forward to the next discrete sample hit.
(output)
(update)
yf
0
tx
d
u,,()=
x
d1+
f
u
tx
d
u,,()=
x
d
(states)
uy
(input) (output)