| Contents | Index |
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 Using Work Vectors.
Note ssSetDWorkName stores only the pointer to the name string. Therefore, the name string 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.
#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.

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 |