필터 지우기
필터 지우기

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

조회 수: 34 (최근 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.
  댓글 수: 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 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