User`s guide

Introduction
3-3
contents. After Simulink calls mdlInitializeSizes, i t t hen interacts with the
S-function through various other routines (all starting with
mdl). At the end of
a simulation,
mdlTerminate is called.
Unlike M-file S-functions, there is not an explicit
flag parameter associated
with each C MEX S-function routine. This is because Simulink automatically
calls each S-function routine at the appro priate time during its interaction
with theS-function. Also, there are S-function routines associated with C MEX
S-functions that don’t have counterparts in M-file S-functions.
Simulink maintainsinformation abouttheS-functionin a datastructure called
the
SimStruct.The#include file, simstruc.h,thatdefinestheSimStruct
providesmacros thatenableyour MEX-fileto set values inand get values(such
as theinput and output signalt o the block) from the
SimStruct.Thestatement
thatincludesthe definitionof the
SimStruct is shownin “StatementsRequired
at the Top of S-Functi onso n page 3–10. The macros that access the
SimStruct
are described in “The C MEX S-Function SimStruct” on page 3–97. Commonly
used macros that are used to access the
SimStruct are des cribed in the
following sections.