| Contents | Index |
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.mdl for a complete example that uses this function.
ssGetStateAbsTol, ssIsVariableStepSolver

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |