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

1 visualización (últimos 30 días)
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 ?

Respuestas (1)

VINAYAK LUHA
VINAYAK LUHA el 15 de Sept. de 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

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by