MATLAB: How to connect multiple input and output ports using a single ADD_LINE function call in Simulink 6.5 (R2006b)

allattachlinesmacrosignalsimulinktogether

I have two blocks in my model. Block 1 has 5 output ports and block 2 has 5 input ports. I would like to connect all five ports (outport 1 to inport1, outport 2 to inport 2, etc) with one call of ADD_LINE.

Best Answer

To connect multiple input output ports using a single call to the ADD_LINE function, you can specify the ports to be connected in a cell array and then call the function with these cell arrays. A short example is shown below:
output = {'Block1/1','Block1/2','Block1/3','Block1/4','Block1/5'};
input = {'Block2/1','Block2/2','Block2/3','Block2/4','Block2/5'};
add_line(gcs,input,output)