How can I comment out Simulink subsystem from Matlab script?

Hi,
I just found out that there is a great option in Simulink which allows to comment out blocks and subsystems and exclude them form simulaton (right-click on block -> Comment out). I'd like to know, how can I do that using Matlab sctipt (or is it even possible?).
Thanks, Krzysztof

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 20 日

4 投票

Suppose your model name is untitled , and you want to comment out the block named Unit Delay
set_param('untitled/Unit Delay','commented','on')
% to uncomment
set_param('untitled/Unit Delay','commented','off')

7 件のコメント

Krzysztof Szczupak
Krzysztof Szczupak 2013 年 9 月 20 日
Wow, that was fast! Thanks!
santhosh
santhosh 2014 年 9 月 18 日
Can this command be applied to a subsystem? I tried it for a subsystem in my model and it didn't work. Any help?
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 9 月 18 日
This should work for any block.
Krzysztof Szczupak
Krzysztof Szczupak 2014 年 9 月 18 日
Yes, this is working also for subsystems. Maybe you're providing wrong path for the subsystem? In the model click on the subsystem you want to comment, then in command window type this command:
set_param(gcb,'commented','on')
( gcb returns path to currently highlighted object on the model). This should comment subsystem you've clicked on.
Shekhar Lokhare
Shekhar Lokhare 2022 年 11 月 29 日
I tried to comment subsystem using above mentioned command but it throws error like invalid object name. I am doing it in 2019b will it support for this version
Dhines
Dhines 2022 年 12 月 15 日
RAGHUVEER RAJESH
RAGHUVEER RAJESH 2023 年 9 月 21 日
Yes. true, its not working for a subsystem. The command is only applicable for simulink blocks. Has anyone else explore some other solution.

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

その他の回答 (1 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by