User`s guide

4 Guidelines for Writing C MEX S-Functions
4-4
The MathWorks has a dopted terminology for these different requirements.
Respectively, the situations described above map to this terminology:
1 Noninlined S-function
2 Wrapper S-function
3 Fully inlined S-function
Noninlined S-Functions
A noninlined S-function is a C-MEX S-function that is treated identically by
Simulink and the Real-Time Workshop. In general, you implement your
algorithm once according to the S-function API. Simulink and the Real-Time
Workshop call the S-function routines (e.g.,
mdlOutputs) at the appropriate
points during model execution.
Significant memory and computation resources are required for each instance
of a noninlined S-function block. However, this routine of incorporating
algorithms into Simulink and the Real-Time Workshop is typical during the
prototyping phase of aprojectwhere efficiencyis notimportant.The advantage
gained by foregoing efficiency is the ability to change model parameters and/or
structures rapidly.
Note that writing a noninlined S-function does not involve any TLC coding.
Noninlined S-functionsare the default case for the Real-Time Workshop in the
sense that once you’ve built a C-MEX S-function in your model, there is no
additional preparation prior to clicking
Build in the RTW Page of the
Simulation Parameters dialog box for your model.
Wrapper S-Functions
A wrapper S-function is ideal for interfacing hand-written code or a large
algorithm t hat is encapsulated within a few procedures. In this situation,
usually the procedures reside in modules that are separate from the C-MEX
S-function. The S-f unction module typically contains a few calls to your
procedures. Since t he S-functi on module does not contain any parts of y our
algorithm, b ut o nly calls yo ur code, it is referred to as a wrapper S-function.
In addition to the C-MEX S-func tion wra p per, you n eed to create a TL C
wrapper that complements your S -function. The TLC wrapper is similar to the
S-function wrapper in that it contains calls to your algorithm.