Updating line connection in Simulink

13 visualizaciones (últimos 30 días)
Iliya Valchev
Iliya Valchev el 17 de Abr. de 2020
Comentada: Iliya Valchev el 21 de Abr. de 2020
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

Respuestas (1)

Jyotsna Talluri
Jyotsna Talluri el 21 de Abr. de 2020
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 comentario
Iliya Valchev
Iliya Valchev el 21 de Abr. de 2020
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

Iniciar sesión para comentar.

Categorías

Más información sobre Physical Units en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by