Property Set Methods
In this section...
“Overview of Property Access Methods” on page 8-56
“Property Set Method Syntax” on page 8-56
“Validate Property Set Value” on page 8-57
“When Set Method Is Called” on page 8-57
Overview of Property Access Methods
For an overview of property access methods, see “Property Access Methods” on page 8-50
Property Set Method Syntax
MATLAB calls a property's set method whenever a value is assigned to the property.
NoteYou cannot call property access methods directly. MATLAB calls these
methods when you access property values.
Property set methods have the following syntax, where PropertyName is the name of the
property.
For a value class:
methods
function obj = set.PropertyName(obj,value)
...
end
- obj — Object whose property is being assigned a value
- value — The new value that is assigned to the property
Value class set functions must return the modified object to the calling function. Handle
classes do not need to return the modified object.
For a handle class:
8 Properties — Storing Class Data