I did not find in the documentation. What is the meaning of set(0,....). What does 0 signify?

I did not find in the documentation. What is the meaning of set(0,....). What does 0 signify? I know that it is the handle? Is the first handle always 0? What does this mean?

 Respuesta aceptada

The 0 refers to the "root", from where all graphics properties are inherited when a figure is created. By changing the values in the root, all graphics objects that are created will inherit that property, unless otherwise specified, eg:
set(0,'DefaultAxesLineStyleOrder',{'-o',':s','--+'})
The documentation of R2010b states:
The root is a graphics object that corresponds to the computer screen. There is only one root object and it has no parent. The children of the root object are figures.
The root object exists when you start MATLAB; you never have to create it and you cannot destroy it. Use set and get to access the root properties.
On more recent version of MATLAB, the 0 has been replaced by groot .

Más respuestas (1)

Hi,
the 0 is the root of the graphics system. It contains information like screen resolution:
get(0)
CallbackObject: []
Children: []
CurrentFigure: []
FixedWidthFontName: 'Courier New'
HandleVisibility: 'on'
MonitorPositions: [1 1 1920 1080]
Parent: []
PointerLocation: [913 357]
ScreenDepth: 32
ScreenPixelsPerInch: 96
ScreenSize: [1 1 1920 1080]
ShowHiddenHandles: 'off'
Tag: ''
Type: 'root'
Units: 'pixels'
UserData: []
Since R2014b handles are objects and not plain numbers. So you can still use the 0 for backward compatibility, but preferred is to use groot instead.
doc groot
Titus

3 comentarios

titus, could you somehow use this to fix the messed up size normalization in GUIDE? You know, like when you set up your GUI layout so that all the controls have their 'units' property set to normalized, and it looks great on your computer, but when someone else runs it on their computer with a different screen size, all the controls are messed up, like they overlap, or the text labels are clipped, etc.? I compile my apps and usually the end-user has less screen resolution than me and a different video adapter, and the layout is all messed up - it's not normalizing properly for them.
Hi IA,
yes, you can. Normalized works fine, but as you already observed, just to some extent. Designing your app on Full HD and run it on a 1024x768 will probably not work.
What I do is to add some switchyard when opening the app, something like
res = get(groot, 'ScreenSize');
if res(3)>=1920
% Full HD
% Set some properties accordingly
elseif res(3)>=1400
% This used to be the resolution of my laptop
else
warning('Low resolution, app will look ugly.');
end
Titus
Well yes, but it's the "Set some properties accordingly" part that I need. I don't know what to change to fix it. I imagine that if the low res computer were setting up the GUI with GUIDE, they could get it to look fine, so what are the properties that I need to change? Just bump down all the font sizes or something? Is there something more global than that? I don't want to manually fix the properties of every single one of the 20 or 30 controls on the GUI if possible.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Centro de ayuda y File Exchange.

Productos

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by