how to find unconnect goto block and from block in the simulink model use script

43 ビュー (過去 30 日間)
wenchao zhang
wenchao zhang 2023 年 8 月 9 日
編集済み: Michael 2023 年 8 月 9 日
hello, i want use the script to find out all the unconnected(or unmatched) goto/from block in the simulink model,which command can i use, i dont know which item of the block i can used to confirm that this block is unconnected. i try check the Goto source, but dont know how to get this item use certain command.

採用された回答

Michael
Michael 2023 年 8 月 9 日
編集済み: Michael 2023 年 8 月 9 日
I think you should find a matching of the "GotoTag" in Goto blocks and From blocks.
First find all your Goto and From blocks in the model
gotoBlocks = find_system(System, 'BlockType', 'Goto'); % return the names of all Goto blocks
fromBlocks = find_system(System, 'BlockType', 'From'); % return the names of all From blocks
Now you have to get all GotoTags parameter in gotoBlocks and fromBlocks cell array. (Example only works for one element of the cell array)
gotoTag = get_param(gotoBlocks{1}, 'GotoTag'); % get the GotoTag of the first Goto block
fromTag = get_param(fromBlocks{1}, 'GotoTag'); % get the GotoTag of the first From block
If there is a connection between a Goto block and a From block then each entry in the gotoTag - array have to match with an entry in the fromTag - array. If an entry in the gotoTag - array has no match with fromTag - array then this Goto block has no connection and if an entry in the fromTag - array has no match with gotoTag - array then this From Block has no connection.
  1 件のコメント
wenchao zhang
wenchao zhang 2023 年 8 月 9 日
thank you,Michael, yes, i think this can work, i have several hundred goto and from block, i need use for loop to check them.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by