Programmatically Set Argument Field Of Simulink Parameter

6 次查看(过去 30 天)
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by