How to set the location of the port with code?
12 views (last 30 days)
Show older comments
In the description of Matlab help: Flexible port placement in Simulink Editor lets you move ports by clicking and dragging the port along the block icon outline, and this way you can put ports on any side of a Subsystem block, including top and bottom. The Port location on the parent subsystem parameter does not have separate values for top or bottom. If you drag a port to a different location on the Subsystem block icon, the parameter value automatically changes to reflect the new placement: Left — The port appears on the left or top side of the subsystem icon. Right — The port appears on the right or bottom side of the subsystem icon.
How to use code to realize the function of changing port location? For example, add a port dynamically and place it on the top of the icon.

0 Comments
Answers (1)
Benjamin Thompson
on 31 Jan 2022
See the article "Programmatic Model Editing" in the Simulink documentation.
5 Comments
Benjamin Thompson
on 2 Feb 2022
You may need to use a combination of the 'Orientation' and 'Side' parameters to achieve the results you want. These properties sound similar to the block rotate and block flip options that you see when you right click on a block and get a pop up menu.
Shinto Thomas
on 21 Dec 2023
Edited: Shinto Thomas
on 21 Dec 2023
How can I place the ports at bottom or top of the subsystem programatically, becasue side parameter has only two inputs left and right.
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!