Use an 'auto' variable from the script in the matlab to simulink solver

9 ビュー (過去 30 日間)
Julien
Julien 2024 年 3 月 6 日
コメント済み: Julien 2024 年 3 月 18 日
Hello,
I would like to modify my simulink solver parameters from an input file loaded by a matlab script.
I would like to modify my simulink solver parameters from an input file loaded by a matlab script. When I add floating numbers, the solver launches without any problem. But if I want to specify in this file the 'auto' function available on Simulink, Simulink does not recognize the variable. Is there a way to give him this information from a workspace variable?
For example this script.m fill in the Simulink solver don't work :
solver.max_step_size = 5e-1;
solver.min_step_size = 5e-3;
solver.initial_step_size = 'auto';
solver.relative_tolerance = 1e-3;
solver.absolute_tolerance = 'auto';
Thnkn for your help,

採用された回答

Fangjun Jiang
Fangjun Jiang 2024 年 3 月 13 日
Yes. This is a problem. A Mathworker might be able to explain why it is done this way. I can provide a workaround solution.
In your script.m, add a line after every parameter that is a string/char array (not a numerical number). For example
solver.initial_step_size = 'auto';
set_param('ModelName','InitialStep', solver.initial_step_size);
Click Help in Configuration Parameters dialog or see this page for the name of the parameters
  2 件のコメント
Fangjun Jiang
Fangjun Jiang 2024 年 3 月 14 日
More generically, see this link and follow the two links at the bottom.
Julien
Julien 2024 年 3 月 18 日
I tried this solution:
set_param('ModelSimulinkName','MaxStep', 'auto');
It doesn't run.
when I add this first line:
activeConfigObj = getActiveConfigSet('ModelSimulinkName');
set_param(activeConfigObj,'MaxStep', 'auto');
It works.
Thanks for your help, I found a solution to do what I want!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by