Changing the size and position of the simulink block

How can I change the position and size of the simulink block from the matlab command window?
sys = 'testmodel';
new_system(sys);
load_system(sys);
add_block('Simulink/Commonly Used Blocks/Subsystem',[sys '/subsystem])
add_block('builtin/Outport','testmodel/ouput1','MakeNameUnique','on')
now i have created one subsystem and one outport.
what are the commands i need to use for changing the model size and position of the block?
Thanks a lot

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 5월 22일
set_param('Model_Name/Block_Name','Position',[50 50 200 100])

댓글 수: 5

How do we change the Size of the Block or Subsytem through set_param
sub_systm = find_system(gcs,'BlockType','Subsystem'); size_blk = get_param(sub_systm{1},'Position'); X = size_blk(1,1); Y = size_blk(1,2); Width = size_blk(1,3); Height = size_blk(1,4); set_param(sub_systm{1},'Position',[X Y X+Width Y+Height]);
hi plz how to get the position of block in model !!
by using get_param
  • get_param(Object,Parameter)
for example, the following code will open the vdp example and will give you the position of the gain block (Mu) inside it:
open_system('vdp')
get_param('vdp/Mu','position')
@Slimeni Omar to get the position of any block in simulink model :
get_param('Model_Name/Block_Name','Position')

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Prerana Ozarkar
Prerana Ozarkar 2019년 3월 5일
편집: Prerana Ozarkar 2019년 3월 5일

3 개 추천

You need to use following command:
get_param(pathOfsystem, 'Position')
this will retuen you a 1X4 matrix in which positions will be stored in a manner [X Y Width Height]

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by