Types of DWork Vectors
All DWork vectors are S-function memory that the Simulink® engine manages. The Simulink software supports four types of DWork vectors:
General DWork vectors contain information of any data type.
DState vectors contain discrete state information. Information stored in a DState vector appears as a state in the linearized model and is available during state logging.
Scratch vectors contain values that do not need to persist from one time step to the next.
Mode vectors contain mode information, usually stored as Boolean or integer data.
S-functions register the DWork vector type using the
ssSetDWorkUsageType macro. This macro
accepts one of the four usage types described in the following table.
|General||Store instance specific persistent data. General DWork vectors can also be used to store discrete state and mode data, however the Simulink engine will not treat this information specially. You might choose to use a general DWork vector to store state information if you want to avoid data logging.|
|DState||Store discrete state information. Using the DState vector instead
|Mode||Indicate to the Simulink engine that the S-function contains modes. The engine handles blocks with modes specially when solving algebraic loops. In addition, the engine updates an S-function with modes only at major time steps. DWork mode vectors are more efficient than standard mode work vectors (see Elementary Work Vectors) because they can store mode information as Boolean data. In addition, while an S-function has only one mode work vectors, it can have multiple DWork vectors configured to store modes.|
|Scratch||Store memory that is not persistent, for example, a large variable
that you do not want to mark on the stack. Scratch vectors are scoped
to a particular S-function method (for example, |