Matlab Class Definition & The Classdef Block

Specifying Attributes and Superclasses

The classdef block contains the class definition. The classdef line is where you specify:

  • Class attributes
  • Superclasses

The classdef block contains the properties, methods, and events subblocks.

Assigning Class Attributes

Class attributes modify class behavior in some way. Assign values to class attributes only when you want to change their default value.

No change to default attribute values:

classdef class_name

One or more attribute values assigned:

classdef (attribute1 = value,...)

See Class Attributes for a list of attributes and a discussion of the behaviors they control.

Specifying Superclasses

To define a class in terms of one or more other classes by specifying the superclasses on the classdef line:

classdef class_name < superclass_name

See Creating Subclasses — Syntax and Techniques for more information.

You may also like...