MATLAB: How to connect a simscape block with add_line

add_linepmcportsSimscapeSimscape Multibody

Hey there, I want to connect a PMC port in SimMechanics automatically with a Matlab-Script. Using the 'add-line' command works fine for common simulink-connections, but not for Simscape-ports. For example if I want to connect the block 'World Frame' with 'Rigid Transform' I use
% code
add_line('mysystem','World Frame/1','Rigid Transform/1')
But then I always get the message:
Invalid Simulink object name: World Frame/1
Does anbody know how to connect these ports in a good way?
Thanks in advance, Thomas

Best Answer

Hi Thomas,
add_line() works with Simscape ports. You have to refer to the ports differently. Try this command:
add_line('mysystem','World Frame/RConn1','Rigid Transform/LConn1');
There is a submission on the MATLAB Central File Exchange that shows how to use MATLAB to automate the construction of a SimMechanics model. The submission "SimMechanics Model from MATLAB Code" shows how to add blocks and connect them using MATLAB commands. The same commands work for Simscape blocks, too.
Hope this helps! --Steve
Related Question