User`s guide

4 Guidelines for Writing C MEX S-Functions
4-10
This figure i llustrates the wrapper S-function concept:
Figure 4-1: How S-Functions Interface with Hand-Written Code
wrapsfcn
wrapsfcn.c
...
mdlOutputs(...)
{
...
my_alg();
}
Simulink
Placethe name of your S-functionin
the S-function block’s dialog box.
S-function
mdlOutputs in
wrapsfcn.mex
calls external
function my_alg
.
my_alg.c
...
real_T my_alg(real_T u)
{
...
y=f(u);
}
In Simulink,the S-function
calls mdlOutputs,which
in turn calls my_alg.
Real-Time Workshop
wrapper.c
,the generated
code, calls MdlOutputs
,
whichthencallsmy_alg.
wrapper.mdl
wrapper.c
...
MdlOutputs(...)
{
...
my_alg();
}
In the TLC wrapper
version of the
S-function, MdlOutputs
in wrapper.exe calls
my_alg
.
*The dotted line above would be the path taken if the S-function did not
havea TLC wrapper file. Ifthere is noTLC wrapper file, thegenerated code
calls
mdlOutputs.
*see note below