mdlSetWorkWidths
Specify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function
Required
No
Languages
C, C++
Syntax
#define MDL_SET_WORK_WIDTHS
void mdlSetWorkWidths(SimStruct *S)
Arguments
S
SimStruct representing an S-Function block.
Description
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. This method specifies the state and work vector sizes via the macros ssSetNumContStates
, ssSetNumDiscStates
, ssSetNumRWork
, ssSetNumIWork
, ssSetNumPWork
, ssSetNumModes
, and ssSetNumNonsampledZCs
.
A C-MEX S-function needs to implement this method only if it does not know the sizes of
all the work vectors it requires when the engine 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
. This method is only valid for simulation, and must be
enclosed in a #if defined(MATLAB_MEX_FILE)
statement.
Examples
For a full example of a C MEX S-function using DWork vectors, see the file
sfun_directlook.c
.
See Also
Version History
Introduced before R2006a