ssSetDWorkName
Specify the name of a Dwork vector
Syntax
const char_T *ssSetDWorkName(SimStruct *S, int_T vector, char_T *name)
Arguments
-
S
-
SimStruct representing an S-Function block.
-
vector
-
Index of the work vector, where the index is one of
0
,1
,2
,...
ssGetNumDWork(S)-1
. -
name
-
Name of a work vector.
Returns
The name of the DWork vector entered inname
.
Description
Use inmdlInitializeSizes
or inmdlSetWorkWidths
to specify a name for the specified Dwork vector. The金宝app®Coder™product uses this name to label the work vector in generated code. If you do not specify a name, theSimulink Coderproduct generates a name for the DWork vector in the code. For more information on using DWork vectors, seeHow to Use DWork Vectors.
Note
ssSetDWorkName
stores only the pointer to the name character vector. Therefore, the name character vector must be in persistent memory; it cannot be a local variable.
Languages
C, C++
Example
The following example dynamically generates and sets the names of multiple DWork vectors.
#define MDL_SET_WORK_WIDTHS #if defined(MDL_SET_WORK_WIDTHS) static void mdlSetWorkWidths(SimStruct *S) { int_T i; /* Number of DWork vectors based on input width */ ssSetNumDWork(S, ssGetInputPortWidth(S,0)); /* Malloc space to store the names of the DWork vectors */ name=(char_T *)malloc(sizeof(char_T)*ssGetNumDWork(S)*16); for (i = 0; i < ssGetNumDWork(S); i++) { sprintf(&name[i*16], "DWork%d", i+1); ssSetDWorkName(S, i, &name[i*16]); } } #endif /* MDL_SET_WORK_WIDTHS */
See the S-functions insfcndemo_sfun_rtwdwork
for a complete example using DWork vectors.