Reorder inports of masked subsystem dynamically
Mostrar comentarios más antiguos
Hi,
I have implemented a masked subsystem with a variable number of Inports by replacing unneeded inputs by Ground blocks. The connections to the inner blocks of the subsystem remain intact. I outline the contents of the subsystem below. The inports are labeled by their name followed by the port index in parenthesis which denotes the order of appearance to the outside of the block.
|----------------|
In1(1) -----> |:1 |
In2(2) -----> |:2 Inner block |
In3(3) -----> |:3 |
In4(4) -----> |:4 |
|----------------|
Assuming In1 is not needed the subsystem looks like this:
|----------------|
Ground -----> |:1 |
In2(1) -----> |:2 Inner block |
In3(2) -----> |:3 |
In4(3) -----> |:4 |
|----------------|
All fine, however when I re-enable the disabled port the index of In1 is obviously wrong because the newly added inport assumes the next free port index.
|----------------|
In1(4) -----> |:1 |
In2(1) -----> |:2 Inner block |
In3(2) -----> |:3 |
In4(3) -----> |:4 |
|----------------|
To avoid confusion I would like to restore the original port indices to match the names like in the very first figure.
I tried to use
set_param('In1', 'Port', '1');
but get a "??? Invalid Simulink object specifier." error.
Thanks for all replies!
Respuesta aceptada
Más respuestas (1)
Albert Yam
el 5 de Sept. de 2012
Lucas' suggestion should be what you require, but from your description, you might be doing this more than once.
I would suggest, using manual switches [MS]. So you can flip inputs off when you need, and not have to change around too much each time. This way, what is connected on the outside, should remain connected, and not have to be rewired.
In1(1)--[MS]->
Ground-/
In2(2)--[MS]->
Ground-/
In3(3)--[MS]->
Ground-/
In4(4)--[MS]->
Ground-/
Disclaimer, no idea how model referencing works, Simulink 6.6.1 here.
Categorías
Más información sobre Programmatic Model Editing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!