Class Components
In this section...
“Class Building Blocks” on page 5-5
“Class Definition Block” on page 5-5
“Properties Block” on page 5-6
“Methods Block” on page 5-6
“Events Block” on page 5-7
“A Complete Class” on page 5-8
“Enumeration Classes” on page 5-8
“Related Information” on page 5-9
Class Building Blocks
MATLAB organizes class definition code into modular blocks, delimited by keywords. All
keywords have an associated end statement:
- classdef...end — Definition of all class components
- properties...end — Declaration of property names, specification of property
attributes, assignment of default values - methods...end — Declaration of method signatures, method attributes, and function
code - events...end — Declaration of event name and attributes
- enumeration...end — Declaration of enumeration members and enumeration
values for enumeration classes.
properties, methods, events, and enumeration are keywords only within a
classdef block.
Class Definition Block
The classdef block contains the class definition within a file that starts with the
classdef keyword and terminates with the end keyword.
Class Components