MATLAB Object-Oriented Programming

(Joyce) #1
classdef (ClassAttributes) ClassName < SuperClass
...
end

For example, this classdef defines a class called MyClass that subclasses the handle
class, but cannot be used to derive subclasses:

classdef (Sealed) MyClass < handle
...
end

See, “Classdef Block” on page 5-10 for more syntax information.

Properties Block


The properties block (one for each unique set of attribute specifications) contains
property definitions, including optional initial values. The properties block starts with the
properties keyword and terminates with the end keyword.

classdef ClassName
properties (PropertyAttributes)
...
end
...
end

For example, this class defines a property called Prop1 that has private access and has a
default value equal to the output of the date function.

classdef MyClass
properties (SetAccess = private)
Prop1 = date
end
...
end

See “Property Definition” on page 8-17 for more information.

Methods Block


The methods block (one for each unique set of attribute specifications) contains function
definitions for the class methods. The methods block starts with the methods keyword
and terminates with the end keyword.

5 Class Definition—Syntax Reference

Free download pdf