Arranging a simulink models inport and outport using a function m-file.
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi , when we build a simulink model it contains many subsystems and its inports and outports will be connected to other blocks randomly arranged(i.e not in line with the ports) .Can you help me writing function so that when i select the subsytem and run the function all the blocks connected to the respective ports are in straight line. and if a inport or outport is not connected to any block connect it to input block or output block respectively...
댓글 수: 0
답변 (1개)
Fangjun Jiang
2011년 9월 12일
I have that function but can't share because it's work related. You could develop your own.
By default, all signal lines are in straight line (vertical or horizontal, not diagonal) unless you are using really old versions of Simulink.
You could write a function to check the connectivity of the Subsystem block using get_param(SubSystemBlock,'PortConnectivity') and then connect ports with the ports of other subsystem block. How to connect depends on what you want because you could match the port block name, or you could match port signal name, or something else. The command to draw the line is add_line(). If you want diagonal line, set the 'autorouting' option to be 'off'.
댓글 수: 2
Fangjun Jiang
2011년 9월 12일
It's not trivial but could be done. My function does the connection by matching port block name.
참고 항목
카테고리
Help Center 및 File Exchange에서 Conditionally Executed Subsystems and Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!