Main Content


Specify the sizes of the work vectors and create the run-time parameters required by this MATLAB S-function









Instance of Simulink.MSFcnRunTimeBlock class representing the Level-2 MATLAB S-Function block.


The Simulink® engine calls this optional method to enable this S-function to set the sizes of state and work vectors that it needs to store global data and to create run-time parameters (see Create and Update S-Function Run-Time Parameters). The engine invokes this method after it has determined the input port width, output port width, and sample times of the S-function. This allows the S-function to size the state and work vectors based on the number and sizes of inputs and outputs and/or the number of sample times.

A Level-2 MATLAB S-function must implement this method if any DWork vectors are used in the S-function. In the case of MATLAB S-functions, this method sets the number of DWork vectors and initializes their attributes. For example, the following code in the PostPropagationSetup method specifies the usage for the first DWork vector:

s.DWork(1).Usage = type;

where s is an instance of the Simulink.MSFcnRunTimeBlock class representing the Level-2 MATLAB S-Function block and type is one of the following:

  • DWork

  • DState

  • Scratch

  • Mode

Version History

Introduced in R2012b