views:

370

answers:

3

We all know MATLAB provides tab-completion for filenames used as arguments in MATLAB function like importdata,imread. How do we do that for the functions we create?

EDIT:

alt text

Displays the files and folders in the current directory.

+1  A: 

There is no supported way to add your functions to the argument Tab completion, but one trick I use is to put a "!" in front of the command so it is treated like a system command. Tab will then complete file paths. Once my MATLAB command is done, I home to the beginning of the line, delete the "!" and press enter.

Mike Katz
@Mike: Yep, that could work I guess.
Jacob
+5  A: 

Caution: unsupported hack here.

Take a look at the file toolbox\local\TC.xml in your Matlab installation. This appears to contain the argument type mappings for tab completion. (I found this by just grepping the Matlab installation for "imread" in R2009b.)

Adding this line inside the <TC> element will get you tab-completion of file names for each of its arguments.

<binding name="importdata"        ctype="FILE"/>

This requires modifying the Matlab installation in place. For some of the other files in toolbox/local, like classpath.txt, you can override them by placing modified copies in the directory you start Matlab from, but this didn't work for TC.xml for me.

Andrew Janke
That's pretty good!
Jacob
wow, spiffy!....
Jason S
+3  A: 

For those interested, I describe the internal format of TC.xml (described above by Andrew) here: http://undocumentedmatlab.com/blog/setting-desktop-tab-completions/

Yair Altman

related questions