Documentation Center

  • Trial Software
  • Product Updates

Class Components

Class Building Blocks – Defining Class Members

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 Classdef Block for more syntax information.

    classdef (ClassAttributes ClassName) 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 Properties for more syntax information.

    classdef ClassName
       properties (PropertyAttributes)
          ...
       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 (MethodAttributes)
          ...
       end
       ...
    end
  • 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. See Specifying Events for more syntax information.

    classdef ClassName
       events (EventAttributes)
          ...
       end
       ...
    end
  • enumeration block contains the enumeration members defined by the class. The enumeration block starts with the enumeration keyword and terminates with the end keyword. See Using Enumeration Classes for more information.

    classdef Boolean < logical
       enumeration
          No  (0)
          Yes (1)
       end
    end

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

More In Depth Information

Class Definition for more detail on class syntax.

Defining Properties for information on specifying properties.

How to Use Methods for information on specifying methods.

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

Defining Named Values for information on creating and using enumeration classes.

Attribute TablesAttribute Tables for a list of all attributes.

Was this topic helpful?