Relative tolerance for solver tolerance calculation
Model Configuration Pane: Solver
Specify the largest acceptable solver error, relative to the size of each state during each time step. If the relative error exceeds this tolerance, the solver reduces the time step size.
At each time step, the solver:
Calculates the value of each state
Estimates the error in each state calculation
Determines the acceptable error for each state using the relative tolerance, absolute tolerance, and state values
The acceptable error considered for each state on each time step is determined by either the relative tolerance or the absolute tolerance, whichever results in a larger tolerance. The solver calculates the acceptable error based on the relative tolerance by multiplying the relative tolerance and the state value.
ei = reltol * |x|,
ei is the acceptable error based on relative tolerance at that time step.
reltol is the value specified for the Relative tolerance parameter.
x is the state value.
When ei is larger than the value specified for the Absolute tolerance parameter, the relative tolerance determines the tolerance for that state on that time step. When the absolute tolerance is greater than ei, the absolute tolerance determines the tolerance for that state on that time step. In general, the absolute tolerance applies when the state values approach zero.
For more information, see Error Tolerances for Variable-Step Solvers.
To enable this parameter:
Set the solver Type to
Set the Solver parameter to a value other than
discrete (no continuous states).
auto| positive scalar number
The relative tolerance indicates the tolerance allowed for the computational accuracy of the variable-step solver as a percentage of each state value. The default value
1e-3 indicates that the computed state value at each time step must be accurate within
The default relative tolerance is appropriate for most applications. Decreasing the relative tolerance can slow simulation.
When you specify the Relative tolerance as
auto, the software uses the default value of
To assess the accuracy of a simulation, reduce the relative tolerance to
1e-4 and simulate the model again. If the results of the two
simulations are not significantly different, the solution has converged.
The table summarizes recommended values for this parameter based on considerations related to code generation.
|Safety precaution||No impact|
|Type: string | character vector|
|Value: positive scalar number|
Introduced before R2006a