end
function obj = set.Style(obj,val)
if ~(strcmpi(val,'-') ||...
strcmpi(val,'--') ||...
strcmpi(val,'..'))
error('Invalid line style ')
end
obj.Style = val;
end
function obj = set.Marker(obj,val)
if ~isstrprop(val,'graphic')
error('Marker must be a visible character')
end
obj.Marker = val;
end
end
end
Create an instance of the class and save its handle:
h = LineType('--','*');
Query the value of any object property using the inherited get method:
get(h,'Marker')
ans =
Set the value of any property using the inherited set method:
set(h,'Marker','Q')
Property Access Methods Called with set and get
MATLAB calls property access methods (set.Style or set.Marker in the LineType
class) when you use the set and get methods.
set(h,'Style','-.-')
Error using LineType>LineType.set.Style
Invalid line style
For more information on property access methods, see “Property Access Methods” on
page 8-50
Implement Set/Get Interface for Properties