Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab completion of custom class methods in Matlab

I made a custom class where files are loaded by the constructor and by methods (the path is given as input), e.g.:

Classdeclaration:

classdef Foo > handle
  methods
    function o = Foo(file), end
    function bar(o,file), end
  end
end

TC.xml file:

  <binding name="Foo" ctype="FILE"/>
  <binding name="bar" ctype="MCOSCLASS FILE"/>

Matlab command prompt:

s = Foo(' + Tab does list available files.

s.bar(' + Tab works

But the problem is that Tab completion is not limited to the class Foo. The trick to change the TC.xsd did not help as well unfortunatly. Yair Altman help me luckely so far to get to this point. Thx again for that.

The whole procedure can be found here:

like image 219
magu_ Avatar asked Nov 12 '13 14:11

magu_


People also ask

How do I find the methods of a class in MATLAB?

methodsview( packagename. classname ) displays information about the methods in the class classname . If the class is in a package, include packagename . If classname is a MATLAB® or Java® class, methodsview lists only public methods, including those methods inherited from superclasses.

How do you call a class in MATLAB?

To call a static method, prefix the method name with the class name so that MATLAB can determine what class defines the method. Call staticMethod using the syntax classname . methodname : r = MyClass.


1 Answers

Firstly, here is a related topic, which contains an answer to a similar question: Tab-completion of filenames as arguments for MATLAB scripts

Then, here is an article on a good Matlab portal on the same topic: Setting desktop tab completions | Undocumented Matlab

UPD: Unfortunately, although there were some TAB-completion improvements introduced in the version R2010a,

Because tab completion uses static analysis, it doesn’t try to guess at the data type for a variable, so things after a “.” such as properties and fields won’t be completed unless that variable is also defined in the workspace.

And it is dubious if there is some more recent info on topic (at least, I did not find any).

Therefore, it is most probably not possible in current version to auto-complete dot properties and methods in MatLab without statically adding all of them to the *.XML file.

Hope that helps!

like image 159
dnl-blkv Avatar answered Oct 27 '22 17:10

dnl-blkv