MATLAB Function Reference
  Go to function:
    Search    Help Desk 
set    Examples   See Also

Set object properties

Syntax

Description

set(H,'PropertyName',PropertyValue,...) sets the named properties to the specified values on the object(s) identified by H. H can be a vector of handles, in which case set sets the properties' values for all the objects.

set(H,a) sets the named properties to the specified values on the object(s) identified by H. a is a structure array whose field names are the object property names and whose field values are the values of the corresponding properties.

set(H,pn,pv,...) sets the named properties specified in the cell array pn to the corresponding value in the cell array pv for all objects identified in H.

set(H,pn,<m-by-n cell array>) sets n property values on each of m graphics objects, where m = length(H) and n is equal to the number of property names contained in the cell array pn. This allows you to set a given group of properties to different values on each object.

a = set(h) returns the user-settable properties and possible values for the object identified by h. a is a structure array whose field names are the object's property names and whose field values are the possible values of the corresponding properties. If you do not specify an output argument, MATLAB displays the information on the screen. h must be scalar.

a = set(0,'Factory') returns the properties whose defaults are user settable for all objects and lists possible values for each property. a is a structure array whose field names are the object's property names and whose field values are the possible values of the corresponding properties. If you do not specify an output argument, MATLAB displays the information on the screen.

a = set(0,'FactoryObjectTypePropertyName') returns the possible values of the named property for the specified object type, if the values are strings. The argument FactoryObjectTypePropertyName is the word Factory concatenated with the object type (e.g., Axes) and the property name (e.g., CameraPosition).

a = set(h,'Default') returns the names of properties having default values set on the object identified by h. set also returns the possible values if they are strings. h must be scalar.

a = set(h,'DefaultObjectTypePropertyName') returns the possible values of the named property for the specified object type, if the values are strings. The argument DefaultObjectTypePropertyName is the word Default concatenated with the object type (e.g., Axes) and the property name (e.g., CameraPosition). For example, DefaultAxesCameraPosition. h must be scalar.

pv = set(h,'PropertyName') returns the possible values for the named property. If the possible values are strings, set returns each in a cell of the cell array, pv. For other properties, set returns an empty cell array. If you do not specify an output argument, MATLAB displays the information on the screen. h must be scalar.

Remarks

You can use any combination of property name/property value pairs, structure arrays, and cell arrays in one call to set.

Examples

Set the Color property of the current Axes to blue:

Change all the Lines in a plot to black:

You can define a group of properties in a structure to better organize your code. For example, these statements define a structure called active, which contains a set of property definitions used for the Uicontrol objects in a particular Figure. When this Figure becomes the current Figure, MATLAB changes colors and enables the controls:

You can use cell arrays to set properties to different values on each object. For example, these statements define a cell array to set three properties:

These statements define a cell array containing three values for each of three objects (i.e., a 3-by-3 cell array):

Now pass the arguments to set,

where length(H) = 3 and each element is the handle to a Uicontrol.

See Also

findobj, gca, gcf, gco, gcbo, get



[ Previous | Help Desk | Next ]