Table of Contents
Why Learning Help and Documentation Matters
Before you can use MATLAB well, you need to know how to help yourself when you are stuck. MATLAB includes a very large amount of built-in help, examples, and reference material. Learning how to find and understand this information early will save you a lot of time and frustration later.
In this chapter you will focus on the different ways to access help and documentation from within MATLAB. You will see how to quickly check what a function does, how to browse the full help system, and how to discover new functions you did not know existed. You will not learn every detail of any specific function here, only how to find those details when you need them.
Using `help` in the Command Window
The simplest way to get information is with the help command in the Command Window. You type the word help, followed by the name of a function or topic, and MATLAB prints a short description directly in the Command Window.
For example, to see basic information about the plot function, you can type
help plotThis shows you a text description, the main syntax forms, and sometimes simple usage examples. Because the output appears right in the Command Window, this method is quick, but the text is plain and not formatted.
If you are not sure what topics exist inside a category, you can type help with no arguments:
helpThis lists groups of functions by category, such as elementary math, graphics, or data types. It is a useful way to explore and discover functions related to a topic.
If you see a function name in code and want to know what it does, help functionName is usually the fastest first step.
Getting Rich Documentation with `doc`
The doc command opens the full Documentation for a function or topic in a separate help browser window. It shows formatted text, headings, examples, and links. For example, to see the detailed documentation for plot, you can type
doc plotThe documentation page that opens will usually contain a description, a full list of input and output arguments, detailed examples with code you can copy, and links to related functions or topics.
If you type doc with no arguments
docMATLAB opens the Documentation home page. From there you can browse by product, topic, or language feature. This is useful when you want a more tutorial style explanation rather than just a function reference.
In general, use help when you want a quick answer in the Command Window, and use doc when you need a complete explanation or examples.
Using the Function Browser and Tooltips
When you type in the Editor or in the Command Window, MATLAB often shows small pop-up hints. If you type a function name followed by a parenthesis, MATLAB displays a tooltip with the basic function syntax. For example, if you type plot( and pause, you should see the syntax hints for plot.
In the Editor, if you hover your mouse over a built-in function name, a small tooltip may appear with a short description and a link such as "View documentation." Clicking this link opens the full doc page for that function.
These quick hints are useful when you only need to confirm the order of inputs or remember what a certain argument means, without leaving your code.
Searching the Documentation
Sometimes you do not know the name of the function you need, or you only know part of a description. In that case, you can search the documentation.
In the help browser (opened by doc or from the Help button on the MATLAB Desktop), there is a search box. You can type keywords, for example "read csv", "linear regression", or "bar plot", and MATLAB will show relevant documentation pages and example files.
You can also search from the Command Window with the doc command by passing a keyword instead of a function name:
doc "csv"This opens search results related to the term "csv". Quotation marks are useful if your search term includes spaces.
Searching is especially important when you are not yet familiar with MATLAB vocabulary. You do not need to guess the exact function name, you can start from a phrase that describes your goal and follow the links from there.
Discovering Functions with `lookfor`
When you want to search by keyword directly in the Command Window, you can use the lookfor command. It scans the first line of help text for many functions and returns those that contain your keyword.
For example, if you want to find functions related to integration, you can type
lookfor integrateMATLAB will list functions whose short help descriptions contain the word "integrate", together with that first line of help text. This helps you discover function names even if you did not know them before.
lookfor can be slower than help or doc, because it searches many files. It is best when you have no idea what the function name might be, and you want to explore a topic by keyword.
Context-Sensitive Help from the MATLAB Desktop
MATLAB provides Help access in several places in the Desktop environment.
In the top bar of the MATLAB Desktop, there is a Help menu and usually a question mark icon. Clicking this opens the Documentation home page or a help browser with context related topics. From there you can browse by product, by topic such as "Getting Started", or by category such as "Language Fundamentals".
In the Editor, if you place the cursor on a function and press F1 (on many systems), MATLAB opens the documentation for that function. This is context-sensitive help, because MATLAB decides which page to open based on where your cursor is.
These shortcuts are useful when you are already working in a file and do not want to type separate help commands in the Command Window.
Viewing Examples and Demos
Many documentation pages contain code examples. Often, there are example sections with headings such as "Examples" or "More About." You can copy and adapt the example code to your own scripts.
Some products include more advanced demos or live scripts as part of the installed documentation. You can often find them by following links like "Open Live Script" on a documentation page. These open a live script containing code and text that you can run and change.
Using examples is a practical way to learn, because you can see working code, run it, and gradually modify it to suit your needs.
Understanding Help Text Format
When you read help text in the Command Window from help functionName, you will usually see certain structure.
At the top, there is a short description line, for example:
plot Create 2-D line plotBelow that, you may see syntax lines that show different ways to call the function, such as
plot(Y)
plot(X,Y)
plot(...,LineSpec)
After the syntax, there may be a longer description, then examples, then a "See also" section. The "See also" section lists related functions in uppercase. You can type help or doc on those names to explore related features.
Learning to scan this format quickly makes it easier to find the piece of information you need without reading everything in detail.
Getting Help for Your Own Functions
When you create your own function files, you can add help text so that help and doc work for them as well. The help text for a user function is written in comment lines at the top of the function file. These lines start with %.
The first comment line becomes the short description line that appears in the Command Window when you use help on your own function. Following comment lines appear as the detailed help.
For example, if a function file starts with
function y = mysum(x)
%MYSUM Sum the elements of a vector.
% Y = MYSUM(X) returns the sum of the elements of vector X.
% This is an example of user-defined help text.then typing
help mysumwill show those comments as help. Adding clear help text to your own functions makes your code easier to reuse and understand, both for yourself in the future and for others.
Online Documentation and Support
In addition to the built-in help, MATLAB documentation is also available online in a web browser. This is useful if you are away from your installed MATLAB or want to share a link to a specific documentation page. The online documentation is usually the most up to date and may include content for newer releases.
From inside MATLAB, many links in the help browser open the same pages in your default web browser. You can also search the web for "matlab functionName" to jump directly to the online reference for that function.
Beyond official documentation, the MathWorks website also provides user communities, answers, and file exchange content. These are not replacements for the built-in documentation, but they can give you ideas, workarounds, or alternative examples when you need them.
When and How to Ask for Help Effectively
Even with good documentation habits, sometimes you will still be stuck. When that happens, it is important to know how to ask for help in a way that makes it easy for others to assist you.
Before asking someone else, try these steps:
First, use help and doc on all functions involved. Second, search the documentation with keywords that describe your problem. Third, try a small minimal example to see if you can reproduce the issue with simple data.
If you still need to ask a person or a user forum, prepare a short, complete code example that shows the problem. Mention any error messages exactly as they appear, describe what you expected to happen, and explain what actually happened. This approach helps others answer quickly and accurately.
Important points to remember:
Use help functionName for quick text help in the Command Window.
Use doc functionName for full, formatted documentation with examples.
Search within the help browser when you do not know the exact function name.
Use lookfor keyword to discover functions by keyword from the Command Window.
Hover tooltips and F1 in the Editor give fast, context-based help about functions.
Write comment-based help at the top of your own function files so help works on them.
Always read error messages and related help pages before asking others for help.