Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
Bonneuil Arnaud
Bonneuil Arnaud le 22 Nov 2012
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 commentaire
Kaustubha Govind
Kaustubha Govind le 26 Nov 2012
Bonneuil: If you don't receive a response here, you should probably contact MathWorks Technical Support about this.

Connectez-vous pour commenter.

Réponses (1)

Sohan Lal
Sohan Lal le 24 Fév 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.

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by