Writing S-Functions | ![]() ![]() |
Specify the sizes of the work vectors and create the runtime parameters required by this S-function.
Syntax
void mdlSetWorkWidths(SimStruct *S)
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 runtime 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 specify the state and work vector sizes via the macros ssNumContStates, 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 mdlIntializeSizes
, 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 | ![]() |