Skip to Main Content Skip to Search
Product Documentation

ssSetDWorkName - Specify the name of a data type work 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 in name.

Description

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 Using Work Vectors.

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

See Also

ssGetDWorkName, ssSetNumDWork

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS