Arranging a simulink models inport and outport using a function m-file.

2 ビュー (過去 30 日間)
SHIVA
SHIVA 2011 年 9 月 12 日
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...

回答 (1 件)

Fangjun Jiang
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 件のコメント
SHIVA
SHIVA 2011 年 9 月 12 日
I have tried this and I am finding difficult in matching block name and matching port name and connecting it .
Thank you for the answer.
Fangjun Jiang
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 ExchangeSubsystems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by