Invalid Simulink object name

조회 수: 80 (최근 30일)
Alicia Roder
Alicia Roder 2017년 3월 23일
편집: Alicia Roder 2017년 3월 24일
I am trying to delete the connecting line between two Simscape blocks using
>> delete_line('PressureGUI','LeakageValve2/1','LeakageValve/1')
where PressureGUI is the name of my Simulink model, LeakageValve2 and LeakageValve are Simscape Valves and the 1s denote the corresponding ports. I have checked the length of the names by using the gcb and length commands. There are no additional blanks in the names.
What am I doing wrong? Thank you!

채택된 답변

Aniruddha Katre
Aniruddha Katre 2017년 3월 23일
From what I looked at, the delete_line function deletes lines connected to "input ports" and "output ports" of blocks. You can see the lines connected to the input/output ports blocks under:
>> A = get_param(gcb,'LineHandles')
In the generated structure A, you will see several fields like Inport, Outport, etc. The delete_line function looks at the inport and outport fields. For Simscape blocks, the lines show up under the LConn and RConn fields since the ports for Simscape blocks are technically not input ports and output ports, they are connection ports with no notion of input or output.
To delete the line connected to a Simscape block, you will need to get the Line Handle for the connection. Here's one way you can do this:
>> A = get_param(gcb,'LineHandles')
>> delete_line(A.LConn) % This will work if the line is connected to the left connection port of the Simscape block.
>> delete_line(A.RConn) % This will work if the line is connected to the right connection port of the Simscape block.
Hope this helps!
  댓글 수: 1
Alicia Roder
Alicia Roder 2017년 3월 24일
편집: Alicia Roder 2017년 3월 24일
Thank you!! It works now. I have just two minor problems now:
If I want to add a line between LConn and RConn though some Simscape elements have two LConns/RConns. How do I specify which ports to connect? Would
>> add_line(A.RConn(1,2),B.LConn(1,2))
to connect the RConn the two second elements in the RConn/LConn Array the correct approach? Up till now I get errors for that.
If I apply your function to Simscape building blocks which have a Simulink Input port aswell, this Connection will not be deleted although it is listed as a RConn in the struct output. How do I adress these conncetions?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Troubleshooting에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by