MATLAB Object-Oriented Programming

(Joyce) #1

The Handle Superclass


In this section...
“Building on the Handle Class” on page 7-13
“Handle Class Methods” on page 7-13
“Event and Listener Methods” on page 7-14
“Relational Methods” on page 7-14
“Test Handle Validity” on page 7-14
“When MATLAB Destroys Objects” on page 7-15

Building on the Handle Class


The handle class is an abstract class. Therefore, you cannot create objects of this class
directly. Use the handle class as a superclass to implement subclasses that inherit
handle behavior. MATLAB defines several classes that derive from the handle class.
These classes provide specialized functionality to subclasses.

Specialized Handle Base Classes

To add both handle behavior and specific functionality to your class, derive your class
from these handle classes:


  • matlab.mixin.SetGet — Provides set and get methods to access property values.

  • dynamicprops — Enables you to define properties that are associated with an object,
    but not the class in general.

  • matlab.mixin.Copyable Provides a copy method that you can customize for your
    class.


For information on how to define subclasses, see “Design Subclass Constructors” on page
12-9.

Handle Class Methods


When you derive a class from the handle class, the subclass inherits methods that enable
you to work more effectively with handle objects.

List the methods of a class by passing the class name to the methods function:

The Handle Superclass
Free download pdf