Getting Help and Documentation
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The reference material consulted while preparing these pages is listed in the section bibliography. |
Written against MATLAB R2026b. The help-text example below was run in GNU Octave 11.3.0, which also reads % comment blocks as help text; MATLAB formats the output differently and adds links. The commands that open the documentation in a browser were checked against the R2026b reference pages and not run here.
Every MATLAB function ships with documentation, and your own functions can carry it too. Knowing the five or six commands on this page, and how to read a reference page, is the fastest way to become productive. The same reading skills are used on every other page of the section, whose Source: lines point at the reference pages described here.
The four ways to ask
The documentation’s own summary lists several ways to get information from the command line (MATLAB documentation: Help and Documentation):
-
doc meanopens the function’s documentation in a separate window (since R2024b, a tab in your system web browser). -
Typing
mean(and pausing shows the function hints: the syntax portion of the documentation, in the Command Window. -
help meanprints an abbreviated, text version in the Command Window. -
The help icon opens the whole product documentation.
help: text in the Command Window
help name displays the first block of comments in the file that defines name, or the abbreviated documentation of a built-in function. For your own code that block is the help text: the comment lines immediately after the function line (or at the top of a script). The first line, the H1 line, is what lookfor searches. Here is a heatflow function with help text:
function dt = stablestep(dx, alpha)
% STABLESTEP Largest stable explicit time step.
% dt = STABLESTEP(dx, alpha) returns dx^2/(4*alpha).
dt = dx^2/(4*alpha);
end
Calling help stablestep prints the comment lines. Octave 11.3.0 printed this (followed by a generic Octave footer that MATLAB does not print; MATLAB adds a link to the documentation):
STABLESTEP Largest stable explicit time step.
dt = STABLESTEP(dx, alpha) returns dx^2/(4*alpha).
Calling the function with the plate spacing 0.1 and the diffusivity 1.1e-4 returned 22.727 in the same run. Writing help text that follows the MATLAB conventions is the subject of Help Text and Documenting Code.
doc: the full reference page
doc name opens the reference page for a function, class, method or product in your system web browser; if the browser is already open but hidden it is brought to the foreground. The details, from the reference page for doc:
-
If
nameis a MathWorks reference page, that page opens.docdoes not display third-party or custom HTML documentation. -
If
nameis a product, its main documentation page opens. -
If there is no reference page but a file named
name.morname.mlxhas help text, the help text is displayed in the browser. -
If neither exists,
docsearches the documentation fornameand shows the results. -
Class members are addressed with a dot:
doc handle,doc handle.findobj, and for packaged classesdoc containers.Map.
doc abs
doc containers.Map
doc
Not run here (they need a browser). With no argument, doc opens the documentation start page. docsearch searches the documentation for words.
Since R2024b the Help browser no longer exists: documentation opens in the system web browser whether you read the web version or the copy installed locally. The documentation installed locally supports offline use, and each example has a Copy Command button that copies an example and its supporting files into your session. Before R2024b doc opened the Help browser, and old books describe it.
lookfor: searching when you do not know the name
lookfor keyword searches the keyword in the one-line summary and the function name of every reference page, and in the help text of third-party and user-written files on the path. Each match shows the H1 line and a link to the help text. lookfor keyword -all widens the search to the Syntax, Description, Input Arguments, Output Arguments and See Also sections of the reference pages.
lookfor inverse
lookfor inverse -all
Not run here (the output depends on the installed products and runs to dozens of lines). The reference page shows lookfor inverse listing acos ("Inverse cosine in radians"), acosd, acosh and so on. lookfor is slow because it scans many files; once you know the name, prefer doc.
Source: MATLAB documentation: lookfor
which and what: where is it?
which item displays the full path of the file that defines item, identifies a workspace variable, and for an overloaded function reports only the first one found. which item -all lists every item with that name on the path, which is how you detect a shadowed function (Function Precedence and Name Resolution). The form str = which(item) returns the path as text. what lists the MATLAB files in a folder, sorted into code files, MAT-files, classes and so on.
which stablestep
s = which("stablestep");
In the same Octave run, which stablestep printed 'stablestep' is a function from the file <folder>/stablestep.m; MATLAB prints the bare path. For a built-in function MATLAB says built-in and gives the path of the file it is built into.
Function hints
After you type the opening parenthesis of a call and pause, MATLAB shows the syntax of the function in the Command Window. They show the syntax portion of the function’s documentation. Your own functions can offer hints too: a functionSignatures.json file in the function’s folder describes their arguments (see Help Text and Documenting Code), and the arguments blocks of Argument Validation declare them in the code itself.
Reading a reference page
Every function page has the same structure, which is worth learning once. The pages carry a release stamp at the top (R2026b today) and, at the bottom, a version history.
| Section | What it gives you |
|---|---|
Syntax |
Every calling form, one per line, from the simplest to the one with all options. Start here. |
Description |
One paragraph per syntax line, saying what each form does. |
Examples |
Short, runnable examples. Many have an Open Live Script or Copy Command link. |
Input Arguments |
Each input, its class and size, and the allowed values. Positional arguments appear first. |
Name-Value Arguments |
Optional settings given as |
Output Arguments |
What each output is, including its class and size. |
Tips, Algorithms, Extended Capabilities |
Edge cases, the method used, and support for GPU arrays, code generation or thread-based environments. |
See Also |
Related functions; a good way to discover alternatives. |
Version History |
The release in which the function was introduced, and each later change. A function marked "not recommended" or removed is explained here, with the replacement. |
Two habits help. Read the Syntax section for the form you need rather than the Description from the top, and check Version History before you rely on something in code that must run on older releases, because it states the release in which an option appeared (for example Name=Value call syntax, R2021a). The Version History is also how this section dates the features it describes.
Learning resources and community
-
MATLAB Onramp is a free, interactive two-hour course that covers the basics in the browser (MATLAB Onramp). The same Academy has an object-oriented programming Onramp.
-
MATLAB Central (https://www.mathworks.com/matlabcentral/) is the community site, with four parts that matter here:
-
MATLAB Answers (https://www.mathworks.com/matlabcentral/answers/) for questions and answers.
-
Cody (https://www.mathworks.com/matlabcentral/cody/) for solving small programming puzzles and learning from other solutions.
-
File Exchange (https://www.mathworks.com/matlabcentral/fileexchange/) for user-contributed code. Since R2026b it is a default repository of the MATLAB Package Manager (see Packages and the MATLAB Package Manager). Review code you download; it is not vetted by MathWorks.
-
Discussions (https://www.mathworks.com/matlabcentral/discussions/) for announcements and conversation.
-
-
MathWorks blogs (https://blogs.mathworks.com/) include The MATLAB Blog and Cleve Moler’s Cleve’s Corner, which is the author of MATLAB writing about its history and numerics.
-
MATLAB Copilot is a separate MathWorks product that adds an AI assistant to MATLAB; it is not part of base MATLAB and is described on its product page.
When you ask a question on a forum, include the release (version -release in R2026b), a minimal example that runs, and the exact error message with its identifier: err.identifier in a catch block (see Errors, Warnings and Exceptions) is what answerers search for.
Pitfalls
-
Searching the web gives answers for the wrong release. Old answers recommend
strmatch,datenumorbsxfun. Check the function’s Version History and see What’s New and Migrating Older Code. -
helpshows nothing for a name when the file has no comment block immediately after thefunctionline, or when a blank line separates them. -
docof your own function opens its help text only if the function has help text; otherwise it searches the documentation, which can open an unrelated page. -
Unfamiliar name, nothing found. Try
which name -all; the item may be a variable that shadows the function.
Where older books differ
Older books say "type helpdesk or open the Help browser". The Help browser was removed in R2024b, and the commands info, helpdesk and whatsnew were removed in R2026a. Use doc and the Help Center in your web browser, and read the release notes on the web (MATLAB release notes).