From: "Steven_Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: subfunctions versus overloaded functions
Date: Wed, 23 Feb 2011 09:46:49 -0500
Organization: MathWorks
Lines: 68
Message-ID: <ik36kp$h1o$>
References: <guh57c$9ko$> <guh9jn$1bk$> <guhae5$q3e$> <guhibb$ghs$> <guhkma$hk7$> <guhpjq$8gs$> <> <ik1nt0$5qk$>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1298472409 17464 (23 Feb 2011 14:46:49 GMT)
NNTP-Posting-Date: Wed, 23 Feb 2011 14:46:49 +0000 (UTC)
In-Reply-To: <ik1nt0$5qk$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:711862

"Mason Freed" <> wrote in message 
> Loren Shure <> wrote in message 
> <>...
>> Actually, since isprime is an MATLAB file and not a built in function, 
>> calling builtin in this case won't work.
>> -- 
>> Loren
> I've run into a similar problem, and came across this thread in my search 
> for a solution. My problem is that I have a CLASS that implements a method 
> called unique, to overload the standard method from toolbox\matlab\ops. 
> Inside my function, I just want to handle a couple special cases that I 
> can speed up with knowledge of the workings of my object, but leave the 
> rest of the cases to the standard unique.m. However, as mentioned, I can't 
> call builtin('unique',args) from within my overloaded class method, 
> because it just says "Cannot find builtin function 'unique'". How can I 
> call the "builtin" version of unique here? Help!

What Loren said for ISPRIME is true for UNIQUE as well.

But your version of UNIQUE is a _method_ of your object, not a subfunction, 

If you call UNIQUE and none of the inputs are instances of your class, then 
MATLAB will not call the method.  So if inside your UNIQUE method you need 
to call UNIQUE on a double array, the UNIQUE that ships with MATLAB would be 
called instead of your method.

classdef myobj
% Invoke as:
% y = myobj([1:10 1:10]);
% unique(y)
        function obj = myobj(x)
   = x;
        function unique(obj)
            disp('Starting UNIQUE method')
            disp('Finishing UNIQUE method')

When you use the commands given in this class's help text, you should see 
the following output:

Starting UNIQUE method
     1     2     3     4     5     6     7     8     9    10

Finishing UNIQUE method

since unique( will NOT invoke the method again.

Steve Lord
To contact Technical Support use the Contact Us link on