Building models with MATLAB Code / separate lines

조회 수: 3 (최근 30일)
Thierry Mallard
Thierry Mallard 2015년 10월 5일
편집: Thierry Mallard 2015년 10월 6일
Hi,
The code below creates 3 blocks and lines between blocks. Using autorouting, Block1/Out4 and Block1/Out5 lines to Block3/In4 and Block3/In5 are on top of each other, which is difficult to follow. When applying this type of script to a more complex system, I loose in readibility and I am looking for a solution.
Is there a way ( autorouting option, parameter?) to progamatically keep lines separated?
I am using MATLAB R2012.
Thanks for your reply.
fname = 'Foo' if exist(fname,'file') == 4 if bdIsLoaded(fname) close_system(fname,0) end delete([fname,'.mdl']); end
new_system(fname);
add_block('built-in/Subsystem', [ fname '/Block1'],... 'Position', [100 100 250 300]);
add_block('built-in/Subsystem', [ fname '/Block2'],... 'Position', [300 100 450 300]);
add_block('built-in/Subsystem', [ fname '/Block3'],... 'Position', [600 300 750 600]);
add_block('built-in/Outport', [fname '/Block1/Out1'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block1/Out2'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block1/Out3'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block1/Out4'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block1/Out5'],... % Id in:1 'Position', [100 100 250 150]);
add_block('built-in/Inport', [fname '/Block2/In1'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block2/In2'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block2/In3'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block2/In4'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block2/In5'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block2/Out1'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block2/Out2'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block2/Out3'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block2/Out4'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Outport', [fname '/Block2/Out5'],... % Id in:1 'Position', [100 100 250 150]);
add_block('built-in/Inport', [fname '/Block3/In1'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block3/In2'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block3/In3'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block3/In4'],... % Id in:1 'Position', [100 100 250 150]); add_block('built-in/Inport', [fname '/Block3/In5'],... % Id in:1 'Position', [100 100 250 150]);
add_line(fname,'Block1/1','Block2/1','autorouting','on'); add_line(fname,'Block1/2','Block2/2','autorouting','on'); add_line(fname,'Block1/3','Block2/3','autorouting','on'); add_line(fname,'Block1/4','Block2/4','autorouting','on'); add_line(fname,'Block1/5','Block2/5','autorouting','on');
add_line(fname,'Block2/1','Block3/1','autorouting','on'); add_line(fname,'Block2/2','Block3/2','autorouting','on'); add_line(fname,'Block1/4','Block3/4','autorouting','on'); add_line(fname,'Block1/5','Block3/5','autorouting','on');
save_system(fname);

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by