Matlab Class Definition & The Classdef Block

April 18th, 2010 Posted in Documents

Specifying and Superclasses

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

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:

1
2
3
classdef class_name
   ...
end

One or more attribute values assigned:

1
2
3
classdef (attribute1 = value,...)
   ...
end

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:

1
2
3
classdef class_name < superclass_name
   ...
end

See Creating — and for more information.

Leave a Reply

You must be logged in to post a comment.