필터 지우기
필터 지우기

Why set_param( block, 'Position', pos ) shift subsystems ?

조회 수: 4 (최근 30일)
Bonneuil Arnaud
Bonneuil Arnaud 2012년 11월 22일
답변: Sohan Lal 2021년 2월 24일
Hi,
I am using this code to resize subsystems in a model :
function format_subsystems( model )
subsystems = find_system(model,'SearchDepth', 1, 'blocktype','SubSystem');
nb_tot = length(subsystems);
for subsystem_index = 1 : 1 : nb_tot
pos = get_param( subsystems{subsystem_index}, 'Position' );
nb_ports = get_param( subsystems{subsystem_index}, 'Ports' );
height = 35 * ( max( nb_ports(1), nb_ports(2)) - 1) + 36 ;
set_param( subsystems{subsystem_index}, 'Position', [ pos(1), pos(2), pos(1) + 100, pos(2) + height ] );
end
end
Example of result :
pos =
350 50 450 150
nb_ports =
1 2 0 0 0 0 0 0
height =
71
Final subsystem position should be :
50 50 150 121
But final subsystem position is :
50 52 150 123
This shift of two pixels is done systematically.
Does anybody can explain me why ? Is there a way to position subsytems as I want ?
Thank you for help.
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2012년 11월 26일
Bonneuil: If you don't receive a response here, you should probably contact MathWorks Technical Support about this.

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

답변 (1개)

Sohan Lal
Sohan Lal 2021년 2월 24일
As per my understanding, you are facing the issue of the subsystem getting shifted a few pixels on setting the new position using the set_param function. This is possible with the pixel alignment. When we set the position, internally it tries to make it pixel align, and this might result in a bit of shift in the position.
We can even see this behavior when we manually move the block position, it will still go with the pixel alignment only.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by