classdef ClassName
properties (PropertyAttribute = value)
Prop1
Prop2
end
endFor example, only methods in the same class definition can modify and query the Salary
and Password properties.classdef EmployeeInfo
properties (Access = private)
Salary
Password
end
endThis restriction exists because the class defines these properties in a properties block
with the Access attribute set to private.Property AttributesFor a description of property attributes you can specify, see, “Property Attributes” on
page 8-9.Property Access Methods
MATLAB calls whenever setting or querying a property value. Define property set access
or get access methods in methods blocks that specify no attributes and have the
following syntax:methodsfunction obj = set.PropertyName(obj,value)
...
endfunction value = get.PropertyName(obj)
...
endendMATLAB does not call the property set access method when assigning the default value
specified in the property's definition block.8 Properties — Storing Class Data