How can I get the variant names inside a Simulink variant subsystem

13 ビュー (過去 30 日間)
Albert Schwinn
Albert Schwinn 2020 年 9 月 14 日
編集済み: Fangjun Jiang 2020 年 9 月 15 日
I have a simple variant subsystem in my Simulink model, where I want to get the names of the subsystems inside. In addition it would be nice to read out the Variant control expression, which is assigned to each subsystem as well.
The subsystem is simple in the sense that it only uses a workspace variable to control the active block. I do not use any variant object, nor do I use the variant manager.

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 9 月 14 日
If you run find_system(), set the 'Variants' option (use 'AllVariants'). For subsystem inside the variant subsystem, the property is "VariantControl"
  2 件のコメント
Albert Schwinn
Albert Schwinn 2020 年 9 月 15 日
Hi,
thanks for the answer. The find_system(), with the option 'AllVariants' is not what I want, because it returns all blocks inside the variants. I solved it now that way:
f = Simulink.FindOptions('SearchDepth',1);
blocksFullName=getfullname(Simulink.findBlocksOfType(modelName,'SubSystem',f));
for jj=1:length(blocksFullName)
VariantCtrl{jj}=get_param(blocksFullName{jj},'VariantControl'); %#ok<*AGROW>
end
modelName is the name of the variant subsystem block, where I want to know the names of the subsystems (possible variants) inside.
Maybe not the most elegant way with the for loop, but it works.
Fangjun Jiang
Fangjun Jiang 2020 年 9 月 15 日
編集済み: Fangjun Jiang 2020 年 9 月 15 日
It is the same as find_system(VariantBlock,'SearchDepth',1,'Variants','AllVariants','BlockType','Subsystem') or
find_system(VariantBlock,'Variants','AllVariants','Parent',VariantBlock,'BlockType','Subsystem')

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by