Include S-function in model


User-Defined Functions


The S-Function block provides access to S-functions from a block diagram. The S-function named as the S-function name parameter can be a Level-1 MATLAB® or a Level-1 or Level-2 C MEX S-function (see S-Function Basics for information on how to create S-functions).


Use the Level-2 MATLAB S-Function block to include a Level-2 MATLAB S-function in a block diagram.

The S-Function block allows additional parameters to be passed directly to the named S-function. The function parameters can be specified as MATLAB expressions or as variables separated by commas. For example,

A, B, C, D, [eye(2,2);zeros(2,2)]

Note that although individual parameters can be enclosed in brackets, the list of parameters must not be enclosed in brackets.

The S-Function block displays the name of the specified S-function and the number of input and output ports specified by the S-function. Signals connected to the inputs must have the dimensions specified by the S-function for the inputs.

Data Type Support

Depends on the implementation of the S-Function block.


S-function name

The S-function name.

S-function parameters

Additional S-function parameters. See the preceding block description for information on how to specify the parameters.

S-function modules

This parameter applies only if this block represents a C MEX S-function and you intend to use the Simulink® Coder™ software to generate code from the model containing the block. If you use it, when you are ready to generate code, you must force the coder to rebuild the top model as explained in Control Regeneration of Top Model Code (Simulink Coder).

For more information on using this parameter, see Specify Additional Source Files for an S-Function (Simulink Coder) in the Simulink Coder documentation.


Data Types

Double | Single | Boolean | Base Integer | Fixed-Point

Sample Time

Depends on contents of S-function

Direct Feedthrough

Depends on contents of S-function

Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


Code Generation


Introduced before R2006a

Was this topic helpful?