Auto-connect block to existing line
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 4 de Sept. de 2012
Editada: Azzi Abdelmalek
el 4 de Sept. de 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
Categorías
Más información sobre Programmatic Model Editing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!