Programmatically Set Argument Field Of Simulink Parameter
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Sandeep Mishra
le 24 Sep 2024
Modifié(e) : Sandeep Mishra
le 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.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Coder dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!