matlab.mixin.SetGet.set - Assign property values - MATLAB (original) (raw)

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

Syntax

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

Description

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

set([H](#buhmbsc-1-H),[pn](#buhmbsc-1-pn),[pv](#buhmbsc-1-pv)) sets the properties in the cell array of strings pn to the corresponding values in the cell array pv for all objects inH. The dimensions of cell array pn must be1-by-n (where n is the number of property names), but the cell array pv can bem-by-n where m is equal tolength(H).

set([H](#buhmbsc-1-H),[s](#buhmbsc-1-S)) sets the properties identified by each field name of the structure s with the values contained in s.

set([H](#buhmbsc-1-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 theName=Value arguments at the end of the argument list.

[sOut](#buhmbsc-1-S-dup1) = set([H](#buhmbsc-1-H)) returns the user-settable properties of scalar H. S is astruct 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](#mw%5Fbfddc866-1484-4fc4-a2b5-18421905bc3a) = set([H](#buhmbsc-1-H),[propname](#mw%5F7520a4f6-ef01-46ae-a610-e2684ebd1fb1)) 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. SeecOut 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.

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