This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Set the absolute tolerance used by a variable-step solver for a specific S-function continuous state.


void ssSetStateAbsTol(SimStruct *S, const int_T idx, const Real_T val)



SimStruct representing an S-Function block.


An index representing an S-function continuous state. This index ranges from 0 to n-1 where n is the number of continuous states in the S-function.


The value of the absolute tolerance. The value must be a positive real scalar.


Use to set the absolute tolerances used for S-function continuous states by the variable-step solver for the current simulation.

    Note   Absolute tolerances are not allocated for fixed-step solvers. Therefore, you should never invoke this macro until you have verified that the simulation is using a variable-step solver. You can use ssIsVariableStepSolver to determine whether or not the model is using a variable-step solver.


C, C++


 * Set the absolute tolerances based on the parameters
static void mdlStart(SimStruct *S)
    const real_T absTol0 = ( mxGetPr(ssGetSFcnParam(S,0)) )[0];
    const real_T absTol1 = ( mxGetPr(ssGetSFcnParam(S,1)) )[0];
    /* Absolute tolerance is not used by fixed-step solvers
     * Therefore every call to absolute tolerance API must be guarded

    if ( ssIsVariableStepSolver(S) ) {
        ssSetStateAbsTol(S, 0, absTol0);    
        ssSetStateAbsTol(S, 1, absTol1);    

See the S-function sfun_atol.c used in sfcndemo_sfun_atol for a complete example that uses this function.

Introduced in R2011a

Was this topic helpful?