Writing S-Functions    

Using S-Functions in Models

To incorporate an S-function into an Simulink model, drag an S-Function block from Simulink's Functions & Tables block library into the model. Then specify the name of the S-function in the S-function name field of the S-Function block's dialog box, as illustrated in the following figure.

Figure 1-1: Relationship Between an S-Function Block, Its Dialog Box,
and the Source File That Defines the Block's Behavior

In this example, the model contains two instances of an S-Function block. Both blocks reference the same source file (mysfun, which can be either a C MEX-file or an M-file). If both a C MEX-file and an M-file have the same name, the C MEX-file takes precedence and is the file that the S-function uses.


  What Is an S-Function? Passing Parameters to S-Functions