Aligning the Inputs and Outputs through m script

51 views (last 30 days)
Please see this link :
I am trying to create the input and output port automatically(thru m script). I am taking the Subsystem portHandles.Inport position and setting the postion for input. Once all the input and output are created, it is mixed with one and other. Please see the link for the screen shot. The signal names are not clearly visible to read. Is there any way to leave the gap between the two input(or output) ports?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 24 Aug 2012
Edited: Azzi Abdelmalek on 24 Aug 2012
try this to understand how to do it
% model1 : your model Name
% sub1: your subsystem name
for k=1:n
x=x0+tailx ;y=y0+taily
inp=['model1/input' num2str(k)]
set_param(inp,'Position',[x0 y0 x y ])
add_line('model1',['input' num2str(k) '/1'],['sub1/' num2str(k)],'autorouting','on' )

Sign in to comment.

More Answers (1)

Albert Yam
Albert Yam on 24 Aug 2012
Imagine a chart over layed on the subsystem. Draw where your margin lines are.
xspacing = [inportL inportR outportL outportR];
%column margins (left/right of blocks)
ystart = 100; % however far down you start
yhalf = 10; % block half width
dy = 30; % height of the row
for ii = 1:insigs
blockname = insig{ii};
setparam(blockname_handle,'Position',[xspacing(1) ystart+ii*dy+yhalf xspacing(2) ystart+ii*dy-yhalf]);
for ii = 1:outsigs
blockname = outsig{ii};
setparam(blockname_handle,'Position',[xspacing(3) ystart+ii*dy+yhalf xspacing(4) ystart+ii*dy-yhalf]);
something like that

Sign in to comment.


Find more on Event Functions 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!