Programmatically Set Argument Field Of Simulink Parameter

3 visualizaciones (últimos 30 días)
Ross
Ross el 24 de Sept. de 2024
Movida: Rena Berman el 15 de Nov. de 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

Respuesta aceptada

Sandeep Mishra
Sandeep Mishra el 24 de Sept. de 2024
Editada: Sandeep Mishra el 24 de Sept. de 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.

Más respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by