User`s guide

Generating Simulink S-Functions
3-7
Generating Simulink S-Functions
You can use the MATLAB Compiler to generate Simulink C MEX S-functions.
This allows you to speed up Simulink models that contain MATLAB M-code
that is referenced from a MATLAB Fcn block.
Note Only the MATLAB Fcn block is supported.
For more information about Simulink in general, see the Simulink
documentation. For more information about Simulink S-functions, see
Writing S-Functions in the Simulink documentation.
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 these 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
Fcn block and the S-Function block are single-input, single-output blocks. 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).