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

1 次查看(过去 30 天)
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?

采纳的回答

Stephen23
Stephen23 2015-1-18
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 .

更多回答(1 个)

Titus Edelhofer
Titus Edelhofer 2015-1-18
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 个评论
Titus Edelhofer
Titus Edelhofer 2015-1-18
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
Image Analyst
Image Analyst 2015-1-18
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by