Superclass of all handle classes
classdef MyHandleClass < handle
To define a handle class, derive your class from
handle using the syntax shown
in the preceding
handle class is the superclass for all classes that follow handle
semantics. A handle is a reference to an object. If you copy an
object's handle variable, MATLAB® copies only the handle. Both the original and copies refer to the same
object. For example, if a function modifies a handle object passed as an input argument,
the modification affects the original input object.
In contrast, nonhandle objects (that is, value objects) are not references. Functions must return modified value objects to change the object outside of the function's workspace.
See Object Modification for information on passing objects to functions.
If you want to create a class that defines events, you must
derive that class from the
handle class is an abstract class, so
you cannot create an instance of this class directly. You use the
to derive other classes, which can be concrete classes whose instances
are handle objects. See Handle Classes for information on using handle classes.
|addlistener||Create event listener bound to event source|
|delete||Delete handle object|
|findobj||Find handle objects|
|isvalid||Determine valid handles|
|listener||Create event listener without binding to event source|
|notify||Notify listeners that event is occurring|
|relationaloperators||Determine equality or sort handle objects|
|Triggered when the handle object is about to be destroyed,
but before calling the |
MATLAB destroys handle objects when there are no references
to the object. You can explicitly remove a handle object by calling
handle class enables you to control what happens
when handle objects are destroyed, either implicitly when no references
exist or explicitly when you delete the object.
deleteMethod in Subclass
handle can define their own
MATLAB calls this method when deleting an object of the subclass, enabling your
subclass to perform any specific actions necessary before deleting a subclass object.
For more information, see Handle Class Destructor.
Any code can respond to the pending deletion of a handle object
by defining a listener for that object’s
ObjectBeingDestroyed event. MATLAB triggers
this event before calling the object’s
For more information on using events and listeners, see Events and Listeners Syntax.
To learn about attributes of classes, see Class Attributes.
classdef MyClass < handle properties Prop1 end events Event1 end methods function obj = MyClass(arg) if nargin > 0 obj.Prop1 = arg; end end end end