Programmatically Set Argument Field Of Simulink Parameter

6 Ansichten (letzte 30 Tage)
Ross
Ross am 24 Sep. 2024
Verschoben: Rena Berman am 15 Nov. 2024
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

Akzeptierte Antwort

Sandeep Mishra
Sandeep Mishra am 24 Sep. 2024
Bearbeitet: Sandeep Mishra am 24 Sep. 2024
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.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by