How to run Simulation for certain amount of time

11 visualizaciones (últimos 30 días)
Peter Pallasch
Peter Pallasch el 11 de Mayo de 2021
Editada: Peter Pallasch el 26 de Abr. de 2023
Hello,
i want to run my Simulation for a certain amount of time and then pause it. I tried with an assertion block which works fine but if i start the simulation through python the assertion block doesn't stop the simulation. Is there a work around?
kind regards

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 11 de Mayo de 2021
Specify the start time and stop time either directly through numerical value, or through variables and then set the value for the variables.
  5 comentarios
Urveshkumar Dharmendrabhai
Urveshkumar Dharmendrabhai el 26 de Abr. de 2023
Thank you for your answer. Would you please clarify what is a
time
in your answer? How and where have you defined 'time' variable?
Peter Pallasch
Peter Pallasch el 26 de Abr. de 2023
Editada: Peter Pallasch el 26 de Abr. de 2023
"time" is not a variable. Its a python module if you refere to the line of code:
import time
time.sleep(30)
The whole point of this Setup was to discretize time. Hence you start your matlab simulation via:
eng.set_param("modelname",'SimulationCommand','continue',nargout=0)
use the python time module to wait 30 seconds by using the python time module via:
import time
time.sleep(30)
and then stop the simulation again via:
eng.set_param("modelname",'SimulationCommand','pause',nargout=0)
Then you can make calculations with the collected data and you have descrete time where every timestep is equal to about 30 secs. The whole thing is controlled via python. Matlab has a python library for that purpose which is included as python module via:
import matlab.engine
All code shown here is no matalb code. I also updated the example code which i think you were refering to. I hope this helps!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Call MATLAB from Python en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by