Clear Filters
Clear Filters

Simulink model doesn't progress further after a few seconds. How to diagnose?

305 views (last 30 days)
My model compiles without warnings, and proceeds to initialise and run quite quickly, say 3 seconds simulation time per 1 second real time. However, after 8 seconds(sim time) or so, it seems not to progress any further. Sometimes it happens at about 8 seconds, sometimes at 9. It depends on the end time I set. It does not freeze, it just doesn't proceed. I've waited half an hour, only to see it make one step of 0.1s further. When I try to stop the simulation, it freezes/crashes. It won't respond to anything and I have to kill MATLAB in Task Manager. I've enabled all warnings, and i've run the model Advisor, but it didn't help me further.
I'm using MATLAB 2018b on Windows 8.1 Pro 64-bit. I'm using the VariableStepAuto option for the solver. I've manually tried some solvers with the same result.
I'm using the Vehicle Network Toolbox for CAN communication and four CAN connections with 2 Vector CAN adapters. I'm not getting problems if I use virtual CAN adapters, problems only occur when I use real CAN adapters. I've updated all their drivers.
How can I diagnose what is making the simulation hang?

Answers (2)

Prajith Chilummula
Prajith Chilummula on 10 Jan 2019
In general, when a simulation looks like it is hanging, it is because the time steps being taken by the solver are becoming very small. You need to make the solver stop taking small steps so that the simulation will progress faster. To do this, you can turn off zero crossings, increase the minimum step size, or increase the minimum tolerance. Information on how to do these and other techniques for speeding up your simulation are available in Chapter 4 of the Using Simulink Guide which can be found on our website at:
Also please check the following answer which might help:
Maximilian Winkelmann
Maximilian Winkelmann on 16 Jan 2022
I have the same issue. My simulation time is very long and it stops at about 1411000 s evertime with no error. Matlab/Simulink just stops working, i cant even open m.-files for example. There is no memory issue or something like that, because it will happen with a start time of 1400000 as well. The solver profiler doesnt work as well as soon as the simulation stops, but the data that is recorded until this point seems to be ok. Based on the profiler there should not be any problem regarding the step size. Is there a solution to this?

Sign in to comment.

yaoxin shen
yaoxin shen on 18 Mar 2022
So, any solution now? I faced the same problem, I wait for nearly an hour but nothing continue. I also have to kill MATLAB in Task Manager.
  1 Comment
Maximilian Winkelmann
Maximilian Winkelmann on 18 Mar 2022
Edited: Maximilian Winkelmann on 18 Mar 2022
Hi, so my problem was a stuck for-loop that never finished running. I identified it by adding a "disp('<loop-name>');" to all my loops and than executing all m-files used in the model seperately. You should see the name of the function in the command windows afterwards. For some reason it did not work if simulink called the m-file functions by itself..

Sign in to comment.


Find more on Configure Simulation Conditions 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!