Writing S-Functions    
mdlCheckParameters

Check the validity of an S-function's parameters.

Syntax

Arguments

S
   SimStruct representing an S-Function block.

Description

Verifies new parameter settings whenever parameters change or are reevaluated during a simulation.

When a simulation is running, changes to S-function parameters can occur at any time during the simulation loop, that is, either at the start of a simulation step or during a simulation step. When the change occurs during a simulation step, Simulink calls this routine twice to handle the parameter change. The first call during the simulation step is used to verify that the parameters are correct. After verifying the new parameters, the simulation continues using the original parameter values until the next simulation step, at which time the new parameter values are used. Redundant calls are needed to maintain simulation consistency.

Example

This example checks the first S-function parameter to verify that it is a real nonnegative scalar.

In addition to the preceding routine, you must add a call to this routine 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:

See matlabroot/simulink/src/sfun_errhdl.c for an example.

Languages

Ada, C

See Also

mdlProcessParameters, ssGetSFcnParamsCount


  S-Function Callback Methods mdlDerivatives