Alex Rivera | Logout

Is it possible to hide the methods inherited from the handle class in matlab?

Asked 2011-07-08T08:26:06.590
14

I'm working on a command line application for ultrasound simulation in MATLAB. Nearly every object in our code is a subclass of handle (to pass as references). The problem I'm having is that all the methods inherited from the handle class shows up under the "Methods" section in MATLAB (see example below).

What I want is to hide the inherited methods from the handle class so that only the function the user is allowed to use is shown under "Methods". This way it doesn't look so messy for the user if he/she wants to know which methods to use.

Example Test class:

classdef Test < handle
    methods
        function myFunction(obj)
        end
    end
end

In the command line:

T = Test()

T = 

  Test handle with no properties.
  Methods, Events, Superclasses

After clicking on "Methods":

Methods for class Test:

Test         delete       findobj      ge           isvalid      lt           ne           
addlistener  eq           findprop     gt           le           myFunction   notify

What I want:

Methods for class Test:

Test         myFunction

Is this possible in MATLAB?

Edit
Report

1 Answer

10

There is a solution here, including sample code.

In short, what you need to do is to overload Matlab's built-in function methods, so that when it is called on your class, it removes the methods of handle from the output. Make sure it works on everything else, though so that you don't mess up your user's other code. If you don't use the @foldername variant to store your class, you could put it into a private directory, for example.

answered 2011-07-08T12:28:47.447

Your Answer