User`s guide
The C MEX S-Function SimStruct
3-97
The C MEX S-Function SimStruct
The file matlabroot/simulink/include/simstruc.h is a C language header
file that definesthe Simulink data structureand the
SimStruct accessma cros.
It encapsulates all the data relating to the model or S-function, including block
parameters and outputs.
There is one
SimStruct data structure allocated for the Simulink model. Each
S-function in the model has its own
SimStruct associated with it. The
organization of these
SimStructs is much like a directory tree. The SimStruct
associated with the model is the root SimStruct.TheSimStructsassociated
with the S-functions are the child
SimStructs.
Note By convention, port indices begin at 0 a nd finish at the total number of
ports minus 1.
The following tables lists the macros that can be used by S-functions to access
the
SimStruct.
Table 3-5: General SimStruct Macros
Macro Description
ssGetModelName(S)
For an S-functio n block, thi s is the na m e of the S-f unction MEX-file
associated with t he bl ock (the term model in this context means an
algorithm defined by your S-function). In the root
SimStruct,this
will be t he name of the Si mulink b lo ck di ag ram.
ssGetPath(S)
For S-function blocks, this is the full Simulink pat h to the
S-function b lock. For the root SimStruct, this is equivalent t o the
model name. Within a C MEX S-function, in
mdlInitializeSizes,
if
strcmp(ssGetModelName(S),ssGetPath(S))==0
the S-function is being called from MATLAB and is not part of a
simulation.