
Stateflow time jumps even with fixed time-step
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to create a State Machine for machinery which uses a PLC and want to simulate the process using Stateflow.
To experiment with Stateflow I added a state called "ON" with the default transition added to it. When starting the simulation, the simulation time (T) rapidly rises to huge numbers, however I expected it to count upwards every 0.1s as in real time. Is it possible to force Simulink from increasing the time so rapidly and have the time increase like in real time?
I have also added an after(30, sec) transition to a state calle "OFF" and the simulation time immediately jumps to this time step and does not increase T every 0.1s until it reaches 30 seconds. I have attached the Example Stateflow Chart to this post.
Following Simulation Settings are set:
Start Time: 0.0
Stop Time: inf (in order to simulate the endless loop of a PLC)
Model Settings -> Solver -> Fixed-Step, Automatic solver selection, 0.1s step size
Chart Properties -> Update method: Inherited
2 Kommentare
Abhipsa
am 28 Mai 2025
As mentioned in the Simulink stop time documentation, the simulation time is not the same as the wall clock time. So, the increment of 0.1sec in simulation time is not the same 0.1s in real-time.
You can refer to the documentation here:
To verify that the time increments by 0.1, you can use the Step Forward option available in the Simulation tab. As illustrated in the figure below, the time correctly advances to T = 0.100, confirming the desired increment.

If you want to achieve real-time increment, you can utilize the Simulation Pacing option present in the Simulation tab.
You can refer to the below MATAB documentation for more information regarding Simulation pacing:
Akzeptierte Antwort
Epsilon
am 28 Mai 2025
Hi Andreas,
The simulation time can be slowed down using ‘Simulation Pacing’ option to match it with real world wall clock duration. To do so please follow these steps:
- Locate the Run button in the Simulate Section in the Simulation tab of the toolstrip.
- Click on the drop-down icon below the run button. The select ‘Simulation Pacing’ from the drop-down.
- In the dialogue box that appears, tick the check box to enable ‘Enable pacing to slow down simulation’ option.
Please also find these attached screenshots for further reference.


Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Decision Logic finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!