ssSetSkipContStatesConsistencyCheck

Ask Simulink engine to skip continuous state consistency check

Syntax

void ssSetSkipContStatesConsistencyCheck(SimStruct *S,boolean_T v)

Arguments

S

SimStruct representing an S-function block.

v

Boolean value (boolean_T) telling Simulink® to skip the continuous state consistency check.

Description

Use this macro to ask Simulink to skip continuous state consistency checks for a correctly written S-function. A correctly written S-function is one that uses the ssSetSolverNeedsReset macro when it changes its own continuous state during major time steps.

By default, Simulink monitors continuous state changes in S-functions. It issues warnings for changes when you do not use the ssSetSolverNeedsReset macro. If you use the ssSetSolverNeedsReset macro correctly, you do not need to have Simulink monitor the continuous state changes in S-functions and can therefore speed up the S-function and improve simulation performance. To tell Simulink to stop monitoring continuous state changes, use the ssSetSkipContStatesConsistencyCheck macro. Use this macro if the S-function:

  • Never changes the state.

  • Changes the state, but uses the ssSetSolverNeedsReset macro to reset the solver.

To skip the checks, use ssSetSkipContStatesConsistencyCheck(S,1) in the mdlInitializeSizes method.

Note

For performance reasons, the continuous state consistency check is performed only in normal and accelerator mode simulations. In particular, Simulink does not perform continuous state consistency checks for:

  • S-functions inside a Model block that is in Accelerator mode

  • Any S-function if the model is running in Rapid Accelerator mode

Languages

C, C++

Example

The following example uses this macro to ask the Simulink engine to skip the consistency check because the S-function has implemented the state change correctly in its mdlOutputs method.

static void mdlInitializeSizes(SimStruct *S)
{
	: 
	: <snip> 
	:    ssSetSkipContStatesConsistencyCheck(SimStruct S,1);
	: 
	: <snip> 
	:
static void mdlOutputs(SimStruct *S, int_T tid)
} /* end mdlInitializeSizes */

static void mdlOutputs(SimStruct *S, int_T tid)
   {
   
        /* Change states in major time step only */
        if ( ssIsMajorTimeStep(S) && YourConditionsForStateChange ) {
           double *x = ssGetContStates(S);
            /* reset the states */
             for (i=0; i<nContStates; i++) {
                 x[i] = 0.0;
             }
            /* Ask the Simulink engine to reset the solver. */
             ssSetSolverNeedsReset(S);
          }
      }

Introduced in R2016a