フィルターのクリア

How to set "Argument" property of a Simulink.Parameter programmatically ?

7 ビュー (過去 30 日間)
Agha
Agha 2023 年 11 月 30 日
編集済み: Fangjun Jiang 2024 年 4 月 3 日
Hello,
I am trying to find a way to programmatically (in MATLAB) set the "Argument" property of a Simulink.Parameter Object which is defined in a Model Workspace.
Using the function getVariablePart this way:
setVariablePart(ModelWorkspace,'Parameter.Argument','on')
will result in following error:
Unrecognized property 'Argument' for class 'Simulink.Parameter'.
Would be very helpful if someone could help.
Kind regards

回答 (2 件)

Jerbin J
Jerbin J 2024 年 2 月 19 日
% To set Argument property of a Simulink.Parameter
% a ,b ,c are parameters in model workspace
set_param(bdroot,'ParameterArgumentNames','a,b,c');
% To uncheck Argument property of a Simulink.Parameter, remove it from the command
set_param(bdroot,'ParameterArgumentNames','a,c');
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2024 年 2 月 19 日
This approach can set the 'ParameterArgumentNames' property of the model itself, but it can not set the 'ParameterArgumentNames' of the "Model" block that references the model.
>> set_param(bdroot,'ParameterArgumentNames','a,b,g')
>> gcb
ans =
'untitled/Model'
>> set_param(gcb,'ParameterArgumentNames','a,b,g')
ModelReference block parameter 'ParameterArgumentNames' is read-only

サインインしてコメントする。


Fangjun Jiang
Fangjun Jiang 2023 年 11 月 30 日
編集済み: Fangjun Jiang 2024 年 4 月 3 日
See below, A Simulink.Parameter object does not have a property called "Argument".
a=Simulink.Parameter
a =
Parameter with properties: Value: [] CoderInfo: [1×1 Simulink.CoderInfo] Description: '' DataType: 'auto' Min: [] Max: [] Unit: '' Complexity: 'real' Dimensions: [0 0]
Update after the discussion in comments. Follow the instruction below
  4 件のコメント
Paul
Paul 2023 年 12 月 1 日
That doc page inludes this statement: " If you decide to re-promote these arguments, set the Argument field to true. "
What does "re-promote" mean?
Fangjun Jiang
Fangjun Jiang 2023 年 12 月 1 日
編集済み: Fangjun Jiang 2023 年 12 月 1 日
My understanding.
The first part of the document describes how to set up parameters for the model (or it is called model arguments). So the "Argument" option checkbox for those two parameters are checked.
The second part describes how to use multiple instances of this model. But when referencing the model, the "Argument" option checkbox for those two parameters are un-checked by default, which means, for any instances, the value for those parameters is still taking the default value in the referenced model and not passed from the main model. The user have to re-check the "Argument" option checkbox at the interface of the particular instance (programmingly or manually, right click the reference block, Block Parameters ModelReference, Instance Parameters) to bring it to the interface of the model block and provide values from the workspace of the main model.
"Promote" probably means to move the parameter from internal to the interface. The first part says "promote it myself" or " make it possible to be promoted". The second part says (from external) "not promoted by default", but a user can "promote it explicitly" or "re-promote".

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel References についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by