This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


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 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


For a full example of a Level-2 MATLAB S-function using DWork vectors, see the file adapt_lms.m used in the Simulink model sldemo_msfcn_lms.

Introduced in R2012b

Was this topic helpful?