delete (handle)

Handle object destructor




delete(h) deletes a handle object, but does not clear the handle variable from the workspace. The handle variable is not valid once the handle object has been deleted.

A subclass of handle can implement a method named delete to perform cleanup tasks just before MATLAB® destroys the handle object. MATLAB calls the delete method of any handle object (if it exists) when the object is destroyed. h is a scalar handle object.

A delete method should not generate errors or create new handles to the object being destroyed. If the delete method has a different signature (having output arguments or more than one input argument) it is not called when the handle objects is destroyed. See Handle Class Destructor information on defining destructors for handle subclasses.

Was this topic helpful?