User`s guide

3 Getting Started with MEX-Files
3-8
Generating Simulink S-Functions
You can use the MATLAB Compile r to generate Simulink C MEX S-functions.
This allow s you to speed up Simulink models that contain MA TLAB M-code
that is referenced from a MATLAB
Fcn block.
Note Only the MATLAB Fcn block is supported.
Formore informationaboutSimulink ingeneral,seeUsingSimulink.Formore
information about Simulink S-functions, see Writing S-Functions.
Simulink-Specific Options
By using Simulink-specific options with the MATLAB Compiler, you can
generate an S-function that is compatible with the S-Function block. The
Simulink-specific options are
-S, -u,and-y. Using any of t hese options with
the MATLAB Compiler causes it to generate code that is compatible with
Simulink.
Using the -S Option
The simplest S-function that the MATLAB Compiler can generate is one with
a dynamically sized number of inputs and outputs. That is, you can pass any
number of inputs and outputs in or out of the S-function. Both the MATLAB
FcnblockandtheS-Functionblock aresingle-input,single-outputblocks. Only
one line can be connected to the input or output of these blocks. However, each
line may be a vector signal, essentially giving these blocks multi-input,
multi-output capability. To generate a C language S-function of this type from
an M-file, use the
-S option
mcc -S mfilename
Note The MATLAB Compiler option that generates a C language S-function
is a capital S (-S).