How to inline/extract subsystem contents in Simulink programmatically

What i would like to do is to extract the contents of a subsystem deleting the subsystem itself.
I know this can be done in system composer using inlineComponent()
but i found no way in Simulink to perform such action. I know the existence of Simulink.SubSystem.copyContentsToBlockDiagram but it only works if the target block diagram is empty, which is not the case.
For example (the simulink is a dummy model):
This is the structure, the red one is the subsystem i would like to inline
this is the content of the subsystem
this is the result of the extaction (the port connection will be performed after and i actually already implemented it)
EDIT: i would really like to avoid looping through the subsystem blocks and copy them one by one since then reconnecting in the correct order them would be a real pain.

 採用された回答

Luca Ferro
Luca Ferro 2023 年 5 月 2 日
編集済み: Luca Ferro 2023 年 5 月 2 日

1 投票

I found the solution to this, i'll keep the question just because it can be useful for someone in need of the same function since i found no other thread with a proper solution about this topic.
The function to use is quite hidden in the documentation and is:
it is incredibly good since it also manages the inport/ouport connection by itself

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSubsystems についてさらに検索

製品

リリース

R2022a

質問済み:

2023 年 5 月 2 日

編集済み:

2023 年 5 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by