Simulink: Set Stop Time from Simulation Input

37 ビュー (過去 30 日間)
Florian Rössing
Florian Rössing 2022 年 12 月 9 日
回答済み: Dongyue 2022 年 12 月 16 日
Hi Everyone,
I set up a simulation routine where I use sim() to invoke multiple simulations with the help of an array of Simulink.SimulationInput Objects
Part of this is, passing a path as one parameter. On Block calls that path and sets the File Name of a From Workspace block, that is used as input to my system. I originally wanted to use that Path also in the Init Function to load another file from that path, where the length of the input signal is stored, which I need as the StopTime of the simulation.
Unfortunately when accessing the ModelWorkspace I a only able to read the default value of the Path and not the one set by the SimulationInput Object. Is there any way to derive the StopTime from the input signal? Or another way to load the information?

回答 (1 件)

Dongyue
Dongyue 2022 年 12 月 16 日
You can use the following command to botain the end time of the simulation from MATLAB command window:
get_param('mymodel1', 'StopTime')
You can also use the command below to set parameter:
set_param('mymodel2','StartTime','5','StopTime','100')
You can read through the documentation for more details:

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by