User`s guide
4 Guidelines for Writing C MEX S-Functions
4-34
} /* end mdlOutputs */
/* Function: mdlTerminate ======================================================
* Abstract:
* Free the cache that was allocated in mdlStart.
*/
static void mdlTerminate(SimStruct *S)
{
SFcnCache *cache = ssGetUserData(S);
if (cache != NULL) {
free(cache);
}
} /* end mdlTerminate */
#define MDL_RTW /* Change to #undef to remove function */
#if defined(MDL_RTW) && (defined(MATLAB_MEX_FILE) || defined(NRT))
/* Function: mdlRTW ============================================================
* Abstract:
* This function is called when the Real-Time Workshop is generating the
* model.rtw file. In this routine, you can call the following functions
* which add fields to the model.rtw file.
*
* Important! Since this S-function has this mdlRTW routine, it must have
* a correSponding .tlc file to work with the Real-Time Workshop. You will find
* the sfun_directlook.tlc in the same directory as sfun_directlook.dll.
*/
static void mdlRTW(SimStruct *S)
{
/*
* Write out the [X,Y] data as parameters, i.e., these values can be
* changed during execution.
*/
{
real_T *xData = mxGetPr(XVECT(S));
int_T xLen = mxGetNumberOfElements(XVECT(S));
real_T *yData = mxGetPr(YVECT(S));
int_T yLen = mxGetNumberOfElements(YVECT(S));
if (!ssWriteRTWParameters(S,2,
SSWRITE_VALUE_VECT,”XData”,””,xData,xLen,
SSWRITE_VALUE_VECT,”YData”,””,yData,yLen)) {
return; /* An error occurred which will be reported by Simulink */
}
}
/*
* Write out the spacing setting as a param setting, i.e., this cannot be
* changed during execution.
*/
{