Writing S-Functions    

Creating Input and Output Ports

Simulink allows S-functions to create and use any number of block I/O ports. This section shows how to create and initialize I/O ports and how to change the characteristics of an S-function block's ports, such as dimensionality and data type, based on its connections to other blocks.

Creating Input Ports

To create and configure input ports, the mdlInitializeSizes method should first specify the number of input ports that the S-function has, using ssSetNumInputPorts. Then, for each input port, the method should specify:

Initializing Input Port Dimensions

The following options exist for setting the input port dimensions:

Sizing an Input Port Dynamically

If your S-function does not require that an input signal have a specific dimensionality, you might want to set the dimensionality of the input port to match the dimensionality of the signal connected to the port. To dimension an input port dynamically, your S-function should:


  Run-Time Parameters Creating Output Ports