This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Specify the name of a data type work vector


const char_T *ssSetDWorkName(SimStruct *S, int_T vector, char_T *name)



SimStruct representing an S-Function block.


Index of the work vector, where the index is one of 0, 1, 2, ... ssGetNumDWork(S)-1.


Name of a work vector.


The name of the DWork vector entered in name.


Use in mdlInitializeSizes or in mdlSetWorkWidths to specify a name for the specified data type work vector. The Simulink® Coder™ product uses this name to label the work vector in generated code. If you do not specify a name, the Simulink Coder product generates a name for the DWork vector in the code. For more information on using DWork vectors, see How 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.


C, C++


The following example dynamically generates and sets the names of multiple DWork vectors.

#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 in sfcndemo_sfun_rtwdwork for a complete example using DWork vectors.

Introduced before R2006a

Was this topic helpful?