Programmically re-order model reference inports in Simulink
3 views (last 30 days)
When you use the model reference block in Simulink you can reorder the inputs (and outputs) of the block dynamically via dragging the input ports in a new order. This action does not change the numbering of the inports inside the referenced model.
Left: The referenced model; Right: The model reference block
Left: The referenced model (still with the same ordering of inputs); Right: The model reference with the ordering changed (via drag-drop)
Now, I want to change the ordering of the model reference block programmically. How can I do this?
I have not found anything in get_param() or get() that could be used to achieve this.
(Although, in PortConnectivity, the Position of the Port is updated when they are moved. However, the PortConnectivity is read-only access only)
Fangjun Jiang on 17 Aug 2023
This is interesting. A user could drag and drop the ports, to a different order or even to the top, bottom or right side of the block. The port "Position" value got changed but you can't set it programmingly because it is read-only.
I don't know what is the practical benefit of moving the ports around, especially in the case that you want to do it programmingly. I knew this feature and it provides some convenience or graphical beauty when connecting blocks manually. But it could also confuse uses regarding the connection. If after all the blocks are connected correctly, a user could move (or by accidental drag and drop) the ports on the left side to a different order. It looks like that the connection has bee changed but it does not.