Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
Bonneuil Arnaud
Bonneuil Arnaud il 22 Nov 2012
Risposto: Sohan Lal il 24 Feb 2021
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 Commento
Kaustubha Govind
Kaustubha Govind il 26 Nov 2012
Bonneuil: If you don't receive a response here, you should probably contact MathWorks Technical Support about this.

Accedi per commentare.

Risposte (1)

Sohan Lal
Sohan Lal il 24 Feb 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.

Categorie

Scopri di più su Subsystems in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by