Documentation

State and Work Vector

Model zero crossings and control memory allocation for S-Function blocks using work vectors

S-Function Callback Methods

mdlInitializeSizesSpecify the number of inputs, outputs, states, parameters, and other characteristics of the C MEX S-function
mdlSetWorkWidthsSpecify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function
mdlOutputsCompute the signals that this block emits
mdlZeroCrossingsUpdate zero-crossing vector
mdlStartInitialize the state vectors of this C MEX S-function
mdlInitializeConditionsInitialize the state vectors of this C MEX S-function
mdlUpdateUpdate a block's states

SimStruct Functions

ssSetNumDWorkSpecify the number of data type work vectors used by a block
ssSetDWorkComplexSignalSpecify whether the elements of a data type work vector are real or complex
ssSetDWorkDataTypeSpecify the data type of a data type work vector
ssSetDWorkNameSpecify the name of a data type work vector
ssSetDWorkUsageTypeSpecify how DWork vector is used in S-function
ssSetDWorkUsedAsDStateSpecify that a data type work vector is used as a discrete state vector
ssSetDWorkWidthSpecify the width of a data type work vector
ssGetNumDWorkGet the number of data type work vectors used by a block
ssGetDWorkGet a DWork vector
ssGetDWorkComplexSignalDetermine whether the elements of a data type work vector are real or complex numbers
ssGetDWorkDataTypeGet the data type of a data type work vector
ssGetDWorkNameGet the name of a data type work vector
ssGetDWorkUsageTypeDetermine how DWork vector is used in S-function
ssGetDWorkUsedAsDStateDetermine whether a data type work vector is used as a discrete state vector
ssGetDWorkWidthGet the size of a data type work vector
ssGetdXGet the derivatives of a block's continuous states
ssSetNumContStatesSpecify the number of continuous states that a block has
ssSetNumDiscStatesSpecify the number of discrete states that a block has
ssSetNumNonsampledZCsSpecify the number of states for which a block detects zero crossings that occur between sample points
ssGetContStatesGet a block's continuous states
ssGetDiscStatesGet a block's discrete states
ssGetRealDiscStatesGet a block's discrete state vector
ssGetNonsampledZCsGet the zero-crossing signal values
ssGetNumContStatesGet the number of continuous states that a block has
ssGetNumDiscStatesGet the number of discrete states that a block has
ssGetNumNonsampledZCsGet the size of the zero-crossing vector
ssSetNumRWorkSpecify the size of a block's floating-point work vector
ssGetNumRWorkGet the size of a block's floating-point work vector
ssGetRWorkGet a block's floating-point work vector
ssGetRWorkValueGet an element of a block's floating-point work vector
ssSetRWorkValueSet an element of a block's floating-point work vector
ssSetNumIWorkSpecify the size of a block's integer work vector
ssGetNumIWorkGet the size of a block's integer work vector
ssGetIWorkGet a block's integer work vector
ssGetIWorkValueGet an element of a block's integer work vector
ssSetIWorkValueSet an element of a block's integer work vector
ssSetNumPWorkSpecify the size of a block's pointer work vector
ssGetNumPWorkGet the size of a block's pointer work vector
ssGetPWorkGet a block's pointer work vector
ssGetPWorkValueGet a pointer from a block's pointer work vector
ssSetPWorkValueSet an element of a block's pointer work vector
ssSetNumModesSpecify the size of the block's mode vector
ssGetNumModesGet the size of the mode vector
ssGetModeVectorGet the mode vector
ssGetModeVectorValueGet an element of a block's mode vector
ssSetModeVectorValueSet an element of a block's mode vector

Examples and How To

Zero Crossings

How to model zero crossings in a C MEX S-function.

Types of DWork Vectors

Describes and compares the functionality of different types of DWork vectors.

How to Use DWork Vectors

How to implement DWork vectors in MATLAB and C MEX S-functions.

DWork Vector Examples

Examples that illustrate the uses of different types of DWork vector.

Elementary Work Vectors

Describes integer, floating-point, pointer, and mode work vectors.

Concepts

DWork Vector Basics

An introduction to the key concepts of DWork vectors.

S-Function Callback Methods

Description of S-function callback methods

S-Function SimStruct Functions

Overview of SimStruct macros and functions.

Was this topic helpful?