Main Content

set

Class: matlab.mixin.SetGet
Namespace: matlab.mixin

Assign specified property-name/property-value pairs

Syntax

set(H,Name,Value,...)
set(H,pn,pv)
set(H,s)
S = set(h)

Description

set(H,Name,Value,...) sets the named property to the specified value for the objects in the handle array H. set matches partial and case-insensitive names that are not ambiguous. Inexact name matching applies only to class properties. Dynamic properties require exact name matches.

set(H,pn,pv) sets the named properties specified in the cell array of strings pn to the corresponding values in the cell array pv for all objects specified in H. The cell array pn must be 1-by-n (where n is the number of property names), but the cell array pv can be m-by-n where m is equal to length(H). set updates each object with the associated set of values for the list of property names contained in.

set(H,s) sets the properties identified by each field name of struct s with the values contained in s. s is a struct whose field names are object property names.

S = set(h) returns the user-settable properties of scalar h. S is a struct whose field names are the object's property names and values that are either empty cell arrays or cell arrays of possible values for properties that have a finite set of predefined possible values.

Input Arguments

expand all

Input handle array, specified as a single handle or an array of handles

Property name, specified as a combination of partial and case-insensitive names. The inexact name must not be ambiguous. Dynamic properties must use exact names.

Data Types: char | string

Property value to assign to the named property, specified as appropriate for that property.

Property names, specified as a cell array of character vectors or scalar strings. The cell array pn must be 1-by-n (where n is the number of property names).

Data Types: cell

Property values, specified as a cell array. The cell array pv can be m-by-n where m is equal to length(H) and n is the number of property names in pn.

Data Types: cell

Property name and value structure. The fields of S correspond to property names and the values of the fields are the property values to set.

Data Types: struct

Scalar object handle. To obtain user-settable properties, input argument must be a scalar object handle.

Output Arguments

expand all

Settable properties, returned as a structure with fields corresponding to property names and values that are either empty cell arrays or cell arrays of possible values for properties that have a finite set of predefined possible values.

Attributes

Accesspublic

To learn about attributes of methods, see Method Attributes.

Examples

Set the value of a property named Data on an instance of a class that derives from matlab.mixin.SetGet.

set(obj,'Data',[1 2 3 4])

Tips

  • Override the matlab.mixin.SetGet class setdisp method to change how MATLAB® displays information returned by set.