Writing S-Functions | ![]() ![]() |
Specify the sizes of the work vectors and create the run-time parameters required by this S-function.
Syntax
Arguments
S
SimStruct representing an S-Function block.
Description
Simulink 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). Simulink 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. This method specifies the state and work vector sizes via the macros ssGetNumContStates, ssSetNumDiscStates, ssSetNumRWork, ssSetNumIWork, ssSetNumPWork, ssSetNumModes, and ssSetNumNonsampledZCs.
The S-function needs to implement this method only if it does not know the sizes of all the work vectors it requires when Simulink invokes the function's mdlInitializeSizes
method. If this S-function implements mdlSetWorkWidths
, it should initialize the sizes of any work vectors that it needs to DYNAMICALLY_SIZED
in mdlInitializeSizes
, even for those whose exact size it knows at that point. The S-function should then specify the actual size in mdlSetWorkWidths
.
Languages
See Also
![]() | mdlSetOutputPortWidth | mdlStart | ![]() |