MATLAB: Add_line or connect or other commands.

add_lineconnectSimscape ElectricalSimscape Electronicssimulink

Hi All,
This might be a simple question but…
I am simulation a rotating machine use the equivalent circuit, and the case has so many resistance to connect different style at each step, so I am trying to connect the up RLC block to the down RLC block (shown in figure) using the "add_line" command.
I have been trying the following line but keep running into an error: add_line('mySys','Ru1/2', 'Rd/1', 'autorouting', 'on')
Error: "Invalid Simulink object name: Ru1/2"
Now both of these ports are different than typical ports. Visually, they are little black circles. Do I need to change the way I identify these types of ports for some reason?
Or, should I have other commands to fix it?
Appreciate any help!!
Thanks!

Best Answer

Check if there is any leading or trailing space in block names and remove the spaces.
If still not working (mysteries Matlab & Simulink...!!!) then try to connect the line using port handles.
SrcBlkH = get_param('mySys/Ru1', 'PortHandles');
DstBlkH = get_param('mySys/Rd1', 'PortHandles');
add_line('mySys', SrcBlkH.Outport(1), DstBlkH.Inport(1), 'autorouting', 'on');
Related Question