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?
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 ofhandlefrom 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@foldernamevariant to store your class, you could put it into aprivatedirectory, for example.