How to run Simulation for certain amount of time

11 ビュー (過去 30 日間)
Peter Pallasch
Peter Pallasch 2021 年 5 月 11 日
編集済み: Peter Pallasch 2023 年 4 月 26 日
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

採用された回答

Fangjun Jiang
Fangjun Jiang 2021 年 5 月 11 日
Specify the start time and stop time either directly through numerical value, or through variables and then set the value for the variables.
  5 件のコメント
Urveshkumar Dharmendrabhai
Urveshkumar Dharmendrabhai 2023 年 4 月 26 日
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 2023 年 4 月 26 日
編集済み: Peter Pallasch 2023 年 4 月 26 日
"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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCall MATLAB from Python についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by