MATLAB Function Reference Previous page   Next Page

Display help for MATLAB functions in Command Window



help lists all primary help topics in the Command Window. Each main help topic corresponds to a directory name on the MATLAB search path.

help / lists all operators and special characters, along with their descriptions.

help functionname displays M-file help, which is a brief description and the syntax for functionname, in the Command Window. The output includes a link to doc functionname, which displays the reference page in the Help browser, often providing additional information. Output also includes see also links, which display help in the Command Window for related functions. If functionname is overloaded, that is, appears in multiple directories on the search path, help displays the M-file help for the first functionname found on the search path, and displays a hyperlinked list of the overloaded functions and their directories. If functionname is also the name of a toolbox, help also displays a list of subdirectories and hyperlinked list of functions in the toolbox, as defined in the Contents.m file for the toolbox.

help toolboxname displays the Contents.m file for the specified directory named toolboxname, where Contents.m contains a list and corresponding description of M-files in toolboxname--see the Remarks topic, Creating Contents Files for Your Own M-File Directories. It is not necessary to give the full pathname of the directory; the last component, or the last several components, are sufficient. If toolboxname is also a function name, help also displays the M-file help for the function toolboxname.

help toolboxname/functionname displays the M-file help for the functionname that resides in the toolboxname directory. Use this form to get direct help for an overloaded function.

help functionname>subfunctionname displays the M-file help for subfunctionname that is in functionname.

help classname.methodname displays help for the method methodname of the fully qualified class classname. If you do not know the fully qualified class for the method, use class(obj), where methodname is of the same class as the object obj.

help classname displays help for the fully qualified class classname.

help syntax displays M-file help describing the syntax used in MATLAB commands and functions.

t = help('topic') returns the help text for topic as a string, with each line separated by /n, where topic is any allowable argument for help.


To prevent long descriptions from scrolling off the screen before you have time to read them, enter more on, and then enter the help statement.

Creating Online Help for Your Own M-Files

The MATLAB help system, like MATLAB itself, is highly extensible. You can write help descriptions for your own M-files and toolboxes using the same self-documenting method that MATLAB M-files and toolboxes use.

The help function lists all help topics by displaying the first line (the H1 line) of the contents files in each directory on the MATLAB search path. The contents files are the M-files named Contents.m within each directory.

Typing help topic, where topic is a directory name, displays the comment lines in the Contents.m file located in that directory. If a contents file does not exist, help displays the H1 lines of all the files in the directory.

Typing help topic, where topic is a function name, displays help for the function by listing the first contiguous comment lines in the M-file topic.m.

Create self-documenting online help for your own M-files by entering text on one or more contiguous comment lines, beginning with the second line of the file (first line if it is a script). For example, the function soundspeed.m begins with

When you execute help soundspeed, MATLAB displays

These lines are the first block of contiguous comment lines. After the first contiguous comment lines, enter an executable statement or blank line, which effectively ends the help section. Any later comments in the M-file do not appear when you type help for the function.

The first comment line in any M-file (the H1 line) is special. It should contain the function name and a brief description of the function. The lookfor function searches and displays this line, and help displays these lines in directories that do not contain a Contents.m file. For the soundspeed example, the H1 line is

Use the Help Report to help you create and manage M-file help for your own files.

Creating Contents Files for Your Own M-File Directories

A Contents.m file is provided for each M-file directory included with the MATLAB software. If you create directories in which to store your own M-files, it is a good practice to create Contents.m files for them, too. Use the Contents Report to help you create and maintain your own Contents.m files.


help close displays help for the close function.

help database/close displays help for the close function in the Database Toolbox.

help datafeed displays help for the Datafeed Toolbox.

help database lists the functions in the Database Toolbox and displays help for the database function, because there are a function and a toolbox called database.

help general lists all functions in the directory $matlabroot/toolbox/matlab/general. This illustrates how to specify a relative partial pathname rather than a full pathname.

t = help('close') gets help for the function close and stores it as a string in t.

See Also

class, doc, docsearch, helpbrowser, helpwin, lookfor, more, partialpath, path, what, which, whos

Previous page  hdftool helpbrowser Next page

© 1994-2005 The MathWorks, Inc.