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

43 次查看(过去 30 天)
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by