Connect two simulink lines programatically

조회 수: 13 (최근 30일)
Igal
Igal 2020년 6월 17일
답변: Fangjun Jiang 2020년 6월 17일
Hi,
I have a need to remove all goto-from block pair (requirement for some project) and perform the connections with lines.
I can make a script that removes all goto-from blocks and I can basically track source for each goto and destination for each from which I can thn connect with add_line, but this appreach is awkward and has certain implementation problems (immagine from block that feeds some things one of which is some other goto block).
What I ould like to do is programatically connect the lines that connect from and to those goto-from pairs. i.e. I remove the blocks with delete_block and then would like to connect the wires that were previously connected to each pair. add_line doesn't seem to accept line handles as argument. So the question is:
How do I programatically connect to simulink lines?

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2020년 6월 17일
%%
Model='ex_goto_tag_visibility_block';
open_system(Model);
Block=[Model,'/GotoGlobal'];
PC=get_param(Block,'PortConnectivity');
P1=PC(1).Position;
delete_block(Block);
Block=[Model,'/From'];
PC=get_param(Block,'PortConnectivity');
P2=PC(1).Position;
delete_block(Block);
add_line(Model,[P1;P2])

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by