How do I programmatically set the Argument checkbox of a model workspace variable?

I'm assigning some variables to a model workspace programmatically and I'm planning on programmatically creating a mask to tune them. I can't figure out how to check the Argument checkbox (programmatically) so that the model mask will be able to use them.

 채택된 답변

Koundinya
Koundinya 2024년 1월 17일
편집: MathWorks Support Team 2023년 12월 20일
To set arguments programmatically, use "set_param" with the model parameter "ParameterArgumentNames". This parameter is a comma-separated string with the names of parameters in the model workspace. For example, if "Ts", "config", and "tunable" are parameters in the model workspace, the below MATLAB code sets them to model arguments:
% Argument checkbox will be checked for the Simulink.Parameter objects Ts,config and tunable
set_param(bdroot,'ParameterArgumentNames','Ts,config,tunable');
To uncheck the Argument checkbox for a parameter, set "ParameterArgumentNames" without that parameter's name in the comma-separated string:
% Argument checkbox for the variable Ts will be unchecked
set_param(bdroot,'ParameterArgumentNames','config,tunable')
See the MATLAB example "Parameterize a Referenced Model Programmatically" for another example of using "ParameterArgumentNames":
https://www.mathworks.com/help/releases/R2023b/simulink/ug/parameterize-referenced-models-example.html

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2019년 5월 21일

편집:

2023년 12월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by