how to find unconnect goto block and from block in the simulink model use script
36 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Michael
on 9 Aug 2023
Edited: Michael
on 9 Aug 2023
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!