Simulink's Simulation Passing not running at appropriate time step?

10 views (last 30 days)
Hey ya,
Any help is greatly apreciated. We are atempting to run a realtime simulink simulation where a participant will be interacting with a simulink simulation. However, after doing a few trial runs we noticed that for every 1 second of real time simulink would only progress by about 0.8 seconds. Out Test is supposed to take only 70 seconds but according to a realworld clock the simulation takes ~85 seconds to complete. another weird thing is that the time delay is consistant and inspute of increasing the simulation speed the Issue persists and can even become worse (dtoping down to 0.7 sim seconds per 1 real world second). Any help is greatly apreciated.

Answers (1)

Umar
Umar on 4 Jul 2024
Hi Benjamin,
The discrepancy in simulation time compared to real-time is often caused by an incorrect time scaling factor in the Simulink model. If the time scaling factor is not set correctly, the simulation may run slower or faster than real-time. So, you need to adjust the time scaling factor in the model settings. Here is an example of how you can set the time scaling factor in Simulink:
% Set the time scaling factor in Simulink set_param('your_model_name', 'SimulationPace', 'realTime');
By setting the 'SimulationPace' parameter to 'realTime', you instruct Simulink to run the simulation in real-time, ensuring that 1 second of real-time corresponds to 1 second in the simulation.

Categories

Find more on Simulink Real-Time in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!