Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Clearing all the references to a handle class object will remove it from memory, and the <code>delete</code> method on your <code>myClass</code> will be called automatically on upon the object being destroyed. It's just unfortunate confusing terminology. Your <code>myClass</code> is an "MCOS class" or "MCOS object", not a "handle graphics object" like <code>help clear</code> is talking about. They're different things, at least at the M-code level.</p> <p>The handle graphics "objects" are not the same type of "object" that your myClass is, and the "handle graphics handle" returned by <code>figure()</code> is not the same sort of thing as the class named <code>handle</code> that you're inheriting from. That passage from <code>help clear</code> talking about "handle graphics handles" doesn't apply to your object. See <code>doc handle</code> and follow the link for the <code>delete</code> method for relevant doco.</p> <p>Don't feel bad; the Matlab doco doesn't make these distinctions very clear. (IIRC it doesn't even explicitly use the term "MCOS"; it just calls them "objects".) Basically, the material under the "Object-Oriented Programming" section in the doco is relevant to the kind of "object" and "handle" you're working on with <code>myClass</code>. The doco under "Graphics" and "GUI Development" is talking about the other handle graphics kind of "object" and "handle". I think they use the term "handle" for the handle graphics stuff and "handle class" for the OOP stuff.</p> <p>To verify that your <code>delete</code> works, just make a trivial class.</p> <pre><code>classdef myClass &lt; handle methods function delete(obj) disp('delete was called'); end end end </code></pre> <p>And then create one and clear it.</p> <pre><code>&gt;&gt; x = myClass x = myClass handle with no properties. Methods, Events, Superclasses &gt;&gt; clear x delete was called &gt;&gt; </code></pre> <p>If your destructor is not being called, there may be other references to the object lingering. The destructor doesn't get called each time a variable holding a reference to the object is cleared, only when the last variable holding a reference (or indirect reference) is cleared. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload