User`s guide
3 Working with MEX-Files
3-8
The result is an S-function described in the following files:
mfilename.c
mfilename.h
mfilename_simulink.c
mfilename.ext
(where ext is the MEX-file 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. These options specifically set the 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 whose with is 2. If you were to connect the
referencing S-Function block to signals that do not correspond to the correct
number of inputs or outputs, Simulink will generate an error when the
simulation starts.
Note The MATLAB Compiler -S option does not support the passing of
parameters, which is normally available with Simulink S-functions.
Specifying S-Function Characteristics
Sample Time
Similar to the MATLAB Fcn block, the automatically generated S-function has
an inherited sample time.