Class Building Blocks

The basic components in the class definition are blocks describing the whole class and specific aspects of its definition:

classdef block contains the class definition within a file that starts with the classdef keyword and terminates with the end keyword. See The Classdef Block for more syntax information.

classdef ClassName
   ...
end

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. See Specifying Properties for more syntax information.

classdef ClassName
   properties
      ...
   end
   ...
end

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. See The Methods Block for more syntax information.

classdef ClassName
   methods
      ...
   end
   ...
end

events block (one for each unique set of attribute specifications) contains the names of events that this class declares. The events blocks starts with the events keyword and terminates with the end keyword. See Specifying Events for more syntax information.

classdef ClassName
   events
      ...
   end
   ...
end

properties, methods, and events are keywords only within a classdef block.

More In Depth Information

Defining Classes — Syntax for more detail on class syntax.

Defining Properties for information on specifying properties.

Class Methods for information on specifying methods.

Defining Events and Listeners — Syntax and Techniques for information on the use of events.

Attribute Tables for a list of all attributes.