Connect two simulink lines programatically

9 vues (au cours des 30 derniers jours)
Igal
Igal le 17 Juin 2020
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?

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 17 Juin 2020
%%
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])

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by