Main Content

get

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

Query specified property values

Syntax

CV = get(H,Name)
SV = get(H)
get(H)

Description

CV = get(H,Name) returns the values of the named property from the objects in the handle array H. If H is scalar, get returns a single value; if H is an array, get returns a cell array of property values. get matches partial and case-insensitive names that are not ambiguous. Inexact name matching applies only to class properties. Dynamic properties require exact name matches.

If you specify a cell array of property names as the second argument, then get returns a cell array of values, where each row in the cell corresponds to an element in H and each column in the cell corresponds to an element in the property name cell array.

If H is nonscalar and Name is the name of a dynamic property, get returns a value only if the property exists in all objects referenced in H.

SV = get(H) returns a structure in which the field names are the object's property names and the values are the current values of the corresponding properties. If H is nonscalar, then SV is a numel(H)-by-1 array of structures.

get(H) displays all property names and their current values for the MATLAB® objects with handle H.

Your subclass can override the matlab.mixin.SetGet getdisp method to control how MATLAB displays this information.

Input Arguments

expand all

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

Property to query, 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

Output Arguments

expand all

Value of queried property, returned as a single value or a cell array of values.

Structure of property names and values, in which the field names are the object's property names and the values are the current values of the corresponding properties.

Data Types: struct

Attributes

Accesspublic

To learn about attributes of methods, see Method Attributes.

Examples

Get the value of a property named Data from an instance of a class derived from matlab.mixin.SetGet.

propValue = get(obj,'Data');

Tips

  • Override the matlab.mixin.SetGet class getdisp method to change how MATLAB displays information returned by get.