Why set_param( block, 'Position', pos ) shift subsystems ?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Kaustubha Govind
el 26 de Nov. de 2012
Bonneuil: If you don't receive a response here, you should probably contact MathWorks Technical Support about this.
Respuestas (1)
Sohan Lal
el 24 de Feb. de 2021
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.
0 comentarios
Ver también
Categorías
Más información sobre Subsystems en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!