In Simulink, how can we assign the simulation time displayed on the top, as a variable ?

3 次查看(过去 30 天)
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 ?

回答(1 个)

VINAYAK LUHA
VINAYAK LUHA 2023-9-15
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

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by