Main Content

ssGetRWorkValue

Get an element of a block's floating-point work vector

Syntax

real_T ssGetRWorkValue(SimStruct *S, int_T idx)

Arguments

S

SimStruct that represents an S-Function block.

idx

Index of the element returned by this function.

Returns

The real_T value stored in the RWork vector element specified by the index idx.

Description

Use to obtain the idx element of the floating-point work vector used by the block represented by S. The vector consists of elements of type real_T and is of length ssGetNumRWork(S). Typically, this vector is initialized in mdlStart or mdlInitializeConditions, updated in mdlUpdate, and used in mdlOutputs. You can use this macro or ssGetRWork to get the current values of the work vector in the simulation loop, mdlInitializeConditions, or mdlStart routines.

Languages

C, C++

Examples

The following statement

real_T v = ssGetRWorkValue(S, 0);

is equivalent to

real_T* wv = ssGetRWork(S);
real_T v = wv[0];

For complete examples using ssGetRWork, see the S-function sfun_dynsize.c used in sfcndemo_sfun_dynsize and the S-function sfunmem.c used in sfcndemo_sfunmem.

Version History

Introduced before R2006a