get

Purpose

Get object properties.

Synopsis

V = get(h,'PropertyName')
get(h)

Description

Use the 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.

Examples

Use get to obtain the handles of objects already on the screen. For example, the following statements create a surface and a text string:

surf(peaks)
text(26,50,7,'The peak of peaks')
If you want to change the color of the text, but did not save its handle when creating it, you can use get to query the properties of the objects in the current axes.

h = get(gca,'Children');
get(h(1),'Type')
          
ans =
    Text
          
get(h(2),'Type')
          
ans =
    Surface
In this case, 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:

get(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
In cases where the property value is a matrix too large to display conveniently, the string too many rows is returned.

See Also

gca, gcf, set

(c) Copyright 1994 by The MathWorks, Inc.