Error occurred while running the simulation

33 views (last 30 days)
I keep getting this error:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Solver encountered an error while simulating model at time 6.6282282635683543e-17 and cannot continue. Please check the model for errors.
Nonlinear iteration is not converging with step size reduced to hmin (2.35482E-31) at time 6.62823E-17. Try reducing the minimum step size and/or relax the relative error tolerance.
I tried changing the solver from 'auto' to 'ode45' as someone suggested in other answers but the simulation now takes "infinite" time.
How could I try to figure out this issue?

Answers (1)

Sam Chak
Sam Chak on 30 Dec 2022
Hi Marco,
In most cases, the problem is likely caused by the singularity event, something like approaching the division-by-zero, or tan(90°). Also check if the system is "stiff" at the beginning of the simulation.
Sam Chak
Sam Chak on 30 Dec 2022
If your Simulink model consists of only fundamental blocks (no mask), then it should be rather easy to detect if there are any division block and trigonometric function block. Sometimes, then problem can be due to the system response is rapidly diverging to . Take a look at this example in MATLAB (not Simulink).
fun = @(t, x) (1e4)*x;
tspan = linspace(0, 10, 1001);
x0 = 1;
[t, x] = ode45(fun, tspan, x0)
t = 1001×1
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900
x = 1001×1
1.0e+260 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 3.7851 NaN NaN NaN
Also check if your system has discontinuities. Best is to post a clear screenshot of the Simulink model. Let the experienced users of Simulink help you to identify the root cause.

Sign in to comment.


Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!