Main Content

set

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

Assign property values

Syntax

set(H,Name=Value)
set(H,pn,pv)
set(H,s)
set(H,___)
sOut = set(H)
cOut = set(H,propname)

Description

set(H,Name=Value) sets property values for the objects in a handle array. This syntax sets property values in handle array H using the Name=Value syntax. Replace Name with the property name and Value with the value for the property. You can include multiple name-value pairs.

set(H,pn,pv) sets the properties in the cell array of strings pn to the corresponding values in the cell array pv for all objects in H. The dimensions of 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(H,s) sets the properties identified by each field name of the structure s with the values contained in s.

set(H,___) sets properties using any combination of the previous syntaxes. If you combine cell array or struct inputs with arguments using the Name=Value syntax, you must add the Name=Value arguments at the end of the argument list.

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

cOut = set(H,propname) returns a cell array of possible values for the property propname if that property has a finite set of predefined values. If the property does not have a finite set of predefined values, the cell array is empty.

Input Arguments

expand all

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

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).

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.

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.

Property name for which to view possible values. See cOut for more information.

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.

Possible property values, returned as a cell array containing a finite set of predefined possible values. If the property does not have a finite set of values, the cell array is empty.

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

  • 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.

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