Programmically re-order model reference inports in Simulink

조회 수: 13 (최근 30일)
Michael Zauner
Michael Zauner 2023년 8월 17일
편집: Fangjun Jiang 2023년 8월 18일
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)

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2023년 8월 17일
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.
  댓글 수: 1
Michael Zauner
Michael Zauner 2023년 8월 18일
My use-case is a bit exotic for it. We have a block with ~300 inputs and outputs where the port-ordering can't be changed due to backwards-compatibility. However, we do not require all inputs und outputs for every use-case. So my goal was to move the ports that are used to the top and the ones that aren't to the bottom. This way, we can connect auxilary systems easily with the "Ctrl+click" functionality (automatically creates lines between two blocks) without having to hand-wire everything.

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

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by