MATLAB Object-Oriented Programming

(Joyce) #1
List All Properties

Return a struct containing object properties and their current values using get:

h = LineType('--','*');
SV = get(h)

SV =

Style: '--'
Marker: '*'
Units: 'points'

Return a struct containing the properties that have public SetAccess using set:

S = set(h)

S =

Style: {}
Marker: {}

The LineType class defines the Units property with SetAccess = protected.
Therefore, S = set(h) does not create a field for Units in S.

set cannot return possible values for properties that have nonpublic set access.

Using get with Arrays of Handles

Suppose that you create an array of LineType objects:

H = [LineType('..','z'),LineType('--','q')]

H =

1x2 LineType with properties:

Style
Marker
Units

When H is an array of handles, get returns a (length(H)-by-1) cell array of property
values:

CV = get(H,'Style')

7 Value or Handle Class — Which to Use

Free download pdf