MATLAB Object-Oriented Programming

(Joyce) #1

classdef ClassName
methods (MethodAttributes)
...
end
...
end


For example:


classdef MyClass
methods (Access = private)
function obj = myMethod(obj)
...
end
end
end


See “Methods and Functions” on page 5-15 for more information.


Events Block


The events block (one for each unique set of attribute specifications) contains the names
of events that this class declares. The events block starts with the events keyword and
terminates with the end keyword.


classdef ClassName
events (EventAttributes)
EventName
end
...
end


For example, this class defined an event called StateChange with a ListenAccess set
to protected:


classdef EventSource
events (ListenAccess = protected)
StateChanged
end
...
end


See “Events and Listeners” on page 5-20 for more information.


Class Components
Free download pdf