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

6 次查看(过去 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...

回答(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 CenterFile Exchange 中查找有关 Schedule Model Components 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by