Auto-connect block to existing line
Afficher commentaires plus anciens
I want to add in some data type conversion blocks infront of some already existing inport blocks. I can create the block and add them to the model and they appear on the port line where I expect them, but they do not connect to that line. They appear above the line and I have to drag them to get them attached to the line. So I was wondering if there was any way I could connect the new block to the line that’s already there from the command line.
Réponse acceptée
Plus de réponses (1)
Azzi Abdelmalek
le 4 Sep 2012
Modifié(e) : Azzi Abdelmalek
le 4 Sep 2012
% the line fom you want connect to your new block "new_block" is an output for a certain block "block1"
%for example new_block is a "constant" block and modelname is the name of your simulink model
add_blck('Simulink/Sources','modelname/new_block')
% to position your block
set_param('modelname/new_block','position' , [x0 y0 x0+x_width y0+y_width])
%connect block
add_line('modelname','block1/1','new_block/1','autorouting','on')
% 'block1/n' means n'th output of block1
% 'new_block/n' means n'th input of new_block
Catégories
En savoir plus sur Programmatic Model Editing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!