MATLAB Answers


The smallest number of Simulink simulation steps

Asked by Pawel Krol on 4 Jul 2019
Latest activity Answered by Sai Bhargav Avula on 29 Jul 2019
What is the smallest number of simulation steps in Simulink? Does it differ for simulation with variable step and constant step?
I am trying to analyse model in Simulink by performing numerous sim() simulations saving state with 'SaveFinalState' and reloading using 'LoadInitialState'. Simulations are with constant step 1 minute. Ultimately, each simulation should be very short - consist of exactly two constant steps:
1) Start at moment defined in T (loaded simState),
2) End exactly at the end of the first step T+1min (determined in StopTime),
Unfortunately, such a script throws an error "The simulation of the model '__' stopped because the stop time is less than or equal to the snapshot time stored in the initial SimState. Increase the stop time if you want to continue the simulation from the specified __.".
The error can be removed by adding second step to simulation "StopTime=T + 2 * 1" insted of "StopTime=T + 1".


Sign in to comment.




1 Answer

Answer by Sai Bhargav Avula on 29 Jul 2019

Yes, the simulation step size varies for fixed and variable step solvers. If the solver is set to ‘auto’, then the simulation step size depends on the simulation time if a fixed-step type is used. If a variable-step type is used, then the simulation step is determined by considering the sample times of all the blocks in the model and then finding the greatest common divisor(gcd) of them.
In the given case, I think that the snapshot time is equal to the stop time which might be the reason for the error. Check the simulation time of the model after loading it. Also, the model’s step size is set to 1-minute which make the solver execute the model only once. Try decreasing step size the model.


Sign in to comment.