Mike on the MATLAB Desktop
January 26th, 2009
Your Table of Contents
MATLAB provides a few command line tools to figure out what functions you have available in a directory. There’s dir, what, and of course, help. Using the help function with a directory (or toolbox) name will list the available functions along with their H1 lines.
By default, MATLAB displays a flat list of files, but if you’d like to control what information is actually displayed, you need to create a Contents.m file. We use Contents.m in toolbox directories to group together related functions, display copyright and version information, and exclude listing helper functions not meant to be called directly.
To create a Contents.m, you must create a new MATLAB-File named “Contents.m”. This file should have all your contents information in a single comments block at the top of the file. This file should not contain any executable code. The text of the comment block becomes the help information. Each directory on your search path can have a Contents.m.
To assist in creating a standard format Contents.m, you can use the Contents Directory Report.
The contents report will look at the MATLAB files in a directory and build a Contents.m file using the filenames and H1 lines. If there already is a Contents.m in a directory. The contents report will identify discrepancies in the file listings or in the H1 lines.
—-Edit 1/26/09 … Loren has just reminded me that that the contents file is Contents.m (with a capital “C”) and not lowercase as I originally mentioned.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
12:55 UTC |
Posted in Current Directory |
Permalink |
5 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
Hello,
For my different projects, I am used to creating Contents.m
It helps me to remind me what my differents function do.
I just regret that it is not possible to save the report in HTML format. Idem for M-Lint Check report, I would find useful to be able to save these reports by using File -> Save As. Currently I use mlintexcel (downloaded from FEx) to send my users the report of their M-lint messages in a Excel Sheet.
Have a nice week ;)
Aurélien
Aurélien,
Thanks for the suggestions, they are good ones.
Mike
Hi,
Is it possible to call this function in a script?
like:
I’ve to update the Contents.m file in several folders, that’s why I need do this automatically.
Any ideas how the command behind the “Contents Report”-Button?
Found it ;-)
(not documented in the MATLAB doc!)
@Daniel,
Ah, you found it! Saves me from having to look it up. You can you run the interactive test with contentsrpt(folderpath), however that file too is unsupported. The makecontentsfile is most likely to change in the next few releases once we hook it up to the help system, the way we have been with the Help Report.