How to get list of constant blocks in model and its default value in Matlab?

50 ビュー (過去 30 日間)
Vamsee Nama
Vamsee Nama 2018 年 8 月 30 日
回答済み: Akhlaq Ahmad 2022 年 4 月 17 日
I would like to see the names of all the constant blocks in my model along with its default values, is there any way to get it?

採用された回答

Stephen
Stephen 2018 年 8 月 30 日
I would recommend you investigate the "find_system" function in the help files.
The first command you need is likely some variant of:
constantBlocks = find_system(bdroot,'LookUnderMasks','all','BlockType','Constant');
I'm not certain what you mean by the "default" values of the constant blocks. But the find_system command will give you a list of constant blocks, which you can cycle through access the strings in the "Value" parameter on each block, if that's what you're looking for.
numConstant = size(constantBlocks,1);
blockValues = cell(numConstant,1);
for ptr = 1:numConstant
blockValues{ptr} = get_param(constantBlocks{ptr},'Value');
end
From there, you should be able to see the value, or evaluate the parameter assigned to the value.
  2 件のコメント
Vamsee Nama
Vamsee Nama 2018 年 8 月 30 日
Thanks, I was using third party Block sets where the constant blocks have a parameter called default value, I was able to extract the values also by modifying a bit of your code.
Mahalakshmi Sivakumar
Mahalakshmi Sivakumar 2021 年 3 月 2 日
do i need to insert any piece of code before this scripts because I got error kindly help me

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

その他の回答 (1 件)

Akhlaq Ahmad
Akhlaq Ahmad 2022 年 4 月 17 日
100x^2+20xy+13y^2 now how can I get only constant in term of matrix or

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by