Download What Is an S
Transcript
mdlCheckParameters
Note You cannot access the work, state, input, output, and other
vectors in this routine. Use this routine only to validate the
parameters. Additional processing of the parameters should be done in
mdlProcessParameters.
Example
This example checks the first S-function parameter to verify that it is
a real nonnegative scalar.
#define PARAM1(S) ssGetSFcnParam(S,0)
#define MDL_CHECK_PARAMETERS
/* Change to #undef to remove function */
#if defined(MDL_CHECK_PARAMETERS) && defined(MATLAB_MEX_FILE)
static void mdlCheckParameters(SimStruct *S)
{
if (mxGetNumberOfElements(PARAM1(S)) != 1) {
ssSetErrorStatus(S,"Parameter to S-function must be a scalar");
return;
} else if (mxGetPr(PARAM1(S))[0] < 0) {
ssSetErrorStatus(S, "Parameter to S-function must be nonnegative");
return;
}
}
#endif /* MDL_CHECK_PARAMETERS */
In addition to the preceding routine, you must add a call to this method
from mdlInitializeSizes to check parameters during initialization,
because mdlCheckParameters is only called while the simulation is
running. To do this, after setting the number of parameters you expect
in your S-function by using ssSetNumSFcnParams, use this code in
mdlInitializeSizes:
8-3
Related documents
Writing S-Functions
MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS User`s guide
Developement Of An Instrument Landing Simulation Using MATLAB
An Integrated, Modular Simulation System for Education and
MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER User`s guide
Simulink User's Guide
Motion Control of Industrial Printers
7.0 User`s Manual - Opal-RT