Aligning the Inputs and Outputs through m script
28 ビュー (過去 30 日間)
古いコメントを表示
Moorthy
2012 年 8 月 24 日
コメント済み: Dharaneedharan Arumugam
2020 年 12 月 8 日
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?
0 件のコメント
採用された回答
Azzi Abdelmalek
2012 年 8 月 24 日
編集済み: Azzi Abdelmalek
2012 年 8 月 24 日
try this to understand how to do it
% model1 : your model Name
% sub1: your subsystem name
tailx=50;taily=25;
x0=50;y0=50;yy0=y0;
for k=1:n
x=x0+tailx ;y=y0+taily
inp=['model1/input' num2str(k)]
add_block('Simulink/Sources/In1',inp)
set_param(inp,'Position',[x0 y0 x y ])
add_line('model1',['input' num2str(k) '/1'],['sub1/' num2str(k)],'autorouting','on' )
y0=y+20
end
4 件のコメント
その他の回答 (1 件)
Albert Yam
2012 年 8 月 24 日
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};
addblock(...)
setparam(blockname_handle,'Position',[xspacing(1) ystart+ii*dy+yhalf xspacing(2) ystart+ii*dy-yhalf]);
end
for ii = 1:outsigs
blockname = outsig{ii};
addblock(...)
setparam(blockname_handle,'Position',[xspacing(3) ystart+ii*dy+yhalf xspacing(4) ystart+ii*dy-yhalf]);
end
something like that
3 件のコメント
Albert Yam
2012 年 8 月 24 日
Think of a box, [], top left corner is x1,y1, bottom right is x2,y2. set_param 'Position' needs x1,y1,x2,y2
inportL = x1 of your inports, the vertical line that you want to align the left of all your inports to.
inportR = x2 of your inports, the vertical line that you want to align the right of all your inports to.
Now when looping inports, x1 and x2 do not change. But y1,y2 does, by ii*dy each iteration, and y1 and y2 are separated by 2*yhalf.
similar for outports
参考
カテゴリ
Help Center および File Exchange で Schedule Model Components についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!