Updating line connection in Simulink

7 次查看(过去 30 天)
Hi,
I am trying to update the connection of a line/signal in Simulink programatically. So fat I was able to retrieve the line information using
h = get_param('some_system/some_block','PortHandles');
ln = get_param(h.LConn, 'Line');
After that I want to change the source or destination port of the line ln, but I did not find a way to do that.
What I want to achieve in the end is to put a block before/after another Simscape block and make sure that all connections from the chosen port pass through the new block which in also connected to all previously connected blocks. If I have Block_A connected to Block_B and Block_C, I want to inject Block_X between them, so Block_A is only connected to Block_X, while Block_X is connected to Block_A on LConn and to Block_B and Block_C on RConn

回答(1 个)

Jyotsna Talluri
Jyotsna Talluri 2020-4-21
You can do that by deleting the lines connected from Block_A to Block_B and Block_A to Block_C.Add a new block Block_X.Then add lines connecting from Block_A to Block_X,Block_X to Block_B and Block_X to Block_C.You can make use of delete_line,add_block and add_line functions respectively for the above operations
Refer to the below documentation links to know more about the functions:
  1 个评论
Iliya Valchev
Iliya Valchev 2020-4-21
Yes, this sounds simple enough. With the Simscape blocks I want to connect there are branches in the lines, so I want to keep their logic. Normally it works to just delete the line from A and connect it to X, but connecting X to B,C...,Z can produce errors since there are already lines to these ports. Additionally I might want to put X "before" A, so the lines from B,C, ..., Z reach X and then X is connected to A.
So far trying to done this has been hard. Even if I use the points of the connection line, sometimes Simulink connects to the nearby port instead

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by