Effacer les filtres
Effacer les filtres

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

6 vues (au cours des 30 derniers jours)
SHIVA
SHIVA le 12 Sep 2011
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...

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 12 Sep 2011
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 commentaires
SHIVA
SHIVA le 12 Sep 2011
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 le 12 Sep 2011
It's not trivial but could be done. My function does the connection by matching port block name.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Schedule Model Components dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by