Documentation Center

  • Trial Software
  • Product Updates

Contents

Improve Simulation Accuracy

To check your simulation accuracy, run the simulation over a reasonable time span. Then, either reduce the relative tolerance to 1e-4 (the default is 1e-3) or reduce the absolute tolerance and run it again. Compare the results of both simulations. If the results are not significantly different, you can feel confident that the solution has converged.

If the simulation misses significant behavior at its start, reduce the initial step size to ensure that the simulation does not step over the significant behavior.

If the simulation results become unstable over time,

  • Your system might be unstable.

  • If you are using ode15s, you might need to restrict the maximum order to 2 (the maximum order for which the solver is A-stable) or try using the ode23s solver.

If the simulation results do not appear to be accurate,

  • For a model that has states whose values approach zero, if the absolute tolerance parameter is too large, the simulation takes too few steps around areas of near-zero state values. Reduce this parameter value or adjust it for individual states in the Integrator dialog box.

  • If reducing the absolute tolerances does not sufficiently improve the accuracy, reduce the size of the relative tolerance parameter to reduce the acceptable error and force smaller step sizes and more steps.

Certain modeling constructs can also produce unexpected or inaccurate simulation results.

  • A Source block that inherits its sample time can produce different simulation results if, for example, the sample times of the downstream blocks are modified (see How Propagation Affects Inherited Sample Times.

  • A Derivative block found in an algebraic loop can result in a loss in solver accuracy.

Was this topic helpful?