Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to cancel a superclasses' overriding of a default Matlab function
    primarykey
    data
    text
    <p>I have two classes, a superclass and subclass. The subclass inherits from the superclass.</p> <p>The superclass redefines the default Matlab function <code>disp()</code>. However, I want the subclass to "cancel" this redefinition and go back to using the default Matlab version of <code>disp()</code>. Is there any way to do this?</p> <p>I know that subclasses can call superclasses' methods via the following syntax</p> <pre><code>function result = CallTheSuperClassMethod(obj, arg1, arg2) result = TheSuperClassMethod@TheSuperClass(obj, arg1, arg2) end </code></pre> <p>But is there a way to call the Matlab default method via something like:</p> <pre><code>function result = CallTheDefaultMethod(obj, arg1, arg2) result = SomeMethod@DefaultClass(obj, arg1, arg2) end </code></pre> <p>where I am assuming that <code>DefaultClass</code> is the class from which all Matlab classes inherit.</p> <p>Here's a concrete example. I have two classes, defined as follows:</p> <pre><code>classdef blah_super properties superprop = 'super property'; end methods function disp(obj) disp('super'); end end end classdef blah_sub &lt; blah_super properties subprop = 'sub property'; end end </code></pre> <p>Here are the results of a few commands that I get:</p> <pre><code>&gt;&gt; a = blah_super a = super &gt;&gt; b = blah_sub b = super </code></pre> <p>But I want to modify <code>blah_sub</code> somehow (while still inheriting from <code>blah_super</code>) so the result is:</p> <pre><code>&gt;&gt; b = blah_sub b = blah_sub with properties: subprop: 'sub property' superprop: 'super property' </code></pre> <p>Thanks in advance.</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.
 

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