Main Content

Handle Classes

Handle classes support reference semantics

A handle class constructor returns a handle object that is a reference to the object created. You can assign the handle object to multiple variables or pass it to functions without causing MATLAB® to make a copy of the original object. For a discussion of how to work with handle objects, see Handle Object Behavior.

Functions

isequalDetermine array equality
eqDetermine equality
matlab.lang.invalidHandleConstruct array of invalid handles (Since R2024b)

Classes

handleSuperclass of all handle classes
matlab.mixin.SetGetProvide handle classes with set and get methods
matlab.mixin.SetGetExactNamesRequire exact name match for set and get methods
dynamicpropsSuperclass for classes that support dynamic properties
matlab.mixin.CopyableSuperclass providing copy functionality for handle objects
matlab.lang.WeakReferenceWeak reference to handle object (Since R2024b)
matlab.lang.HandlePlaceholderBasic subclass of handle (Since R2024b)

Methods

addlistenerCreate event listener bound to event source
listenerCreate event listener without binding to event source
notifyNotify listeners that event is occurring
deleteDelete handle object
findobjFind handle objects
findpropFind matlab.metadata.Property object
isvalidDetermine valid handles
relationaloperatorsDetermine equality or sort handle objects

Topics

Characteristics of Handle and Value Classes

Building on the Handle Class

  • The Handle Superclass
    The handle class implements methods to support events and listeners, destructors, relational operations, and other operations.
  • Handle Class Destructor
    Define a delete method to customize what happens when MATLAB destroys handle objects.

Working with Handle Classes