V = get(h,'PropertyName')
get(h)
get
function to obtain the current values of object properties. The handle argument h
identifies the object whose properties you are querying.
V = get(h,'PropertyName')
returns the current value of the specified property of the object identified by the handle h
.
get(h)
, without a property name, lists all the properties that apply to the object with the handle h
, along with their current values.
To query the value of any default property, concatenate the word Default
with the object type and the property name. For example, to obtain the default value of the Color
property for figure objects, use the following command:
get(0,'DefaultFigureColor')
To obtain a list of all default values currently defined by an object for its descendants, use
get(h,'Default')
where h
is the handle of the object.
get
to obtain the handles of objects already on the screen. For example, the following statements create a surface and a text string:
If you want to change the color of the text, but did not save its handle when creating it, you can usesurf(peaks)
text(26,50,7,'The peak of peaks')
get
to query the properties of the objects in the current axes.
In this case,h = get(gca,'Children');
get(h(1),'Type')
ans =
Text
get(h(2),'Type')
ans =
Surface
h(1)
contains the handle of the text object. You can now use this handle to set the text color:
set(h(1),'Color',[1 0 0])
To obtain a list of the surface's properties and their current values, use get
on the surface's handle:
In cases where the property value is a matrix too large to display conveniently, the stringget(h(2))
CData = [ (too many rows) ]
EdgeColor = black
FaceColor = flat
LineStyle = -
MarkerSize = [6]
MeshStyle = both
XData = [(1 by 49) ]
YData = [ (49 by 1) ]
ZData = [ (49 by 49) ]
Children = []
Clipping = on
Parent = [10.000366211]
Type = Surface
UserData = []
Visible = on
too
many
rows
is returned.
gca
,gcf
,set
(c) Copyright 1994 by The MathWorks, Inc.