In Simulink, how can we assign the simulation time displayed on the top, as a variable ?
2 views (last 30 days)
Show older comments
I am running a simulation model in Simulink. How can we assign the simulation time displayed on the top, as a variable ? How can we run the simulation from 0 to 5 sec, with time interval after every 0.05 sec (thus creating a running window after every 0.05 sec time step, while simulating the model and feeding the data to the matlab function block to get the desired output), by assigning the simulation time as a variable ?
Answers (1)
VINAYAK LUHA
on 15 Sep 2023
Hi Siddhath,
It is my understanding that you wish to know to run a Simulink model with variable stop times and timesteps.
Here’s a workaround using the “sim” command -
modelName = 'modelName';
for t = 0:1:5
simOut = sim(modelName, 'StopTime', num2str(t), 'FixedStep', num2str(0.05));
end
The above code runs the Simulink model with stop time increasing every 1 second and with “fixed” step size of 0.05 seconds.
Explore the “sim” function documentation for more details, Here's the link https://in.mathworks.com/help/simulink/slref/sim.html
Hope this helps!
Regards,
Vinayak Luha
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!