Programmatically Set Argument Field Of Simulink Parameter

8 ビュー (過去 30 日間)
Ross
Ross 2024 年 9 月 24 日
移動済み: Rena Berman 2024 年 11 月 15 日
Hello,
Does anyone know how to programmatically set the argument field of a Simulink Parameter, shown in the attached image?
For context, I have a model with a large number of parameters that is used for code generation, and I want to be able to load them all into the model workspace. Have managed to get everything else configured autonomously except this argument field.
Many Thanks,
Ross

採用された回答

Sandeep Mishra
Sandeep Mishra 2024 年 9 月 24 日
編集済み: Sandeep Mishra 2024 年 9 月 24 日
Hi Ross,
To set the Argument property of the Simulink.Parameter object, you can leverage the set_param function in MATLAB. This function allows you to manage the ParameterArgumentNames property, which takes a string of parameter names whose Argument values should be checked.
For example, if you have two Simulink.Parameter objects, Param1 and Param2’ , you can use the following code snippet to check the 'Argument' property:
% Initializing and loading the Model named 'model_name'
load_system('model_name');
% Checking Argument for Both Param1 and Param2
set_param(model, 'ParameterArgumentNames', 'Param1,Param2');
% Checking Argument only for Param1
set_param(model, 'ParameterArgumentNames', 'Param1');
To uncheck the Argument property for specific parameters, you can remove those parameters from the string and pass only the ones you want to keep checked.
Refer to the following example code snippet
% Unchecking Param1 and checking Param2
set_param(model, 'ParameterArgumentNames', 'Param2');
% Unchecking all parameters
set_param(model, 'ParameterArgumentNames', '');
Please refer to the following MathWorks Documentation to learn more about ‘set_param’ function in MATLAB: https://www.mathworks.com/help/releases/R2021b/simulink/slref/set_param.html
I hope this helps you in solving the issue.
  1 件のコメント
Ross
Ross 2024 年 9 月 24 日
移動済み: Rena Berman 2024 年 11 月 15 日
Perfect, thank you very much @Sandeep Mishra!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by