User`s guide
Generating Simulink S-Functions
3-9
The result is an S-function described in the follow ing files.
mfilename.c
mfilename.h
mfilename_simulink.c
mfilename.ext
(where ext is the MEX-f ile extension for your
platform, e.g.,
dll for Windows )
Using the -u and -y Options
Using the -S option by itself will generate code suitable for most general
applications. However, if you would like to exert more control over the number
of valid inputs or outputs for your function, you should use the
-u and/or -y
options.Theseoptionsspecificallysetthe number of inputs (u) and the number
of outputs (
y) for your function. If either -u or -y is omitted, the respective
input or output will be dynamically sized.
mcc -S -u 1 -y 2 mfilename
In the above line, the S-function will be generated with an input vector whose
width is 1 and an output vector w hose with is 2 . If you were to connect the
referencing S-function block to signals that do not correspond t o the correct
number of inputs or outputs, Simulink will generate an error when the
simulation starts.
Note The MATLAB C ompiler -S option does not support the passing of
parameters that is normally available with Simulink S-functio ns.
Specifying S-Function Characteristics
Sample Time
Similar to the MATLAB Fcn block, the automatically generated S-function has
an inherited sample time.