| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
To help you better find elements, such as matching if/else statements, some entries appear in different colors in the Command Window. This is known as syntax highlighting. You can change the colors using preferences. Note that output in the Command Window does not appear with syntax highlighting, except for errors. Syntax highlighting is also available in other desktop tools. For more information, see Setting Colors Preferences for Desktop Tools

You can instruct the MATLAB software to notify you about matched and unmatched delimiters. For example, when you type a parenthesis, bracket, or brace, MATLAB highlights the matched delimiter in the pair. To use the delimiter matching feature, select File > Preferences > Keyboard > Delimiter Matching. This feature is also available in the Editor.
For more information, see Setting Delimiter Matching Preferences.
MATLAB helps you complete the names of known items as you type them in the Command Window so that you can avoid spelling mistakes and do not have to spend time looking up the information in other tools. These are the items for which MATLAB can complete the names:
Functions or models on the search path or in the current folder
MATLAB objects
File names and folders, including object-oriented programming package and class folders
Variables, including structures, in the current workspace
Handle Graphics property names
Type the first few characters of the item name and then press the Tab key. To use tab completion, you must have the tab completion preference for the Command Window selected. For details, see Setting Keyboard Preferences for Desktop Tools.
Tab completion is also available in the Editor, but there are some slight differences in usage. See Completing Statements in the Editor — Tab Completion.
These examples demonstrate how to use tab completion in the Command Window:
This example illustrates a basic use for tab completion. After creating a variable, costs_march, type
costs
and press Tab. MATLAB automatically completes the name of the variable, displaying
costs_march
Then complete the statement, adding any arguments, operators, or options, and press Return or Enter to run it. In this example, if you just press Enter, MATLAB displays the contents of costs_march. If MATLAB does not complete the name costs_march but instead moves the cursor to the right, you do not have the preference set for tab completion. If MATLAB displays No Completions Found, costs_march does not exist in the current workspace.
You can use tab completion anywhere in the line, not just at the beginning. For example, if you type
a = cost
and press Tab, MATLAB completes costs_march. You can also select co or position the cursor after co and press Tab to complete costs_march.
If there is more than one name that starts with the characters you typed when you press the Tab key, MATLAB displays a list of all names that start with those characters. For example, type
cos
and press Tab. MATLAB displays

The resulting list of possible completions includes the variable name you created, costs_march, but also includes functions that begin with cos, including cosets from the Communications Toolbox™ software, if it is installed on the system and on the search path in MATLAB. MATLAB completes variable names in the currently selected workspace, and the names of functions and models on the search path or in the current folder.
Continue typing to make your entry unique. For example, type the next character, such as t in the example. MATLAB selects the first item in the list that matches what you typed, in this case, costs_march. Press Enter (or Return) or Tab to select that item, which completes the name at the prompt. In the example, MATLAB displays costs_march at the prompt. Add any arguments, and press Enter again to run the statement.
You can navigate the list of possible completions using up and down arrow keys, and Page Up and Page Down keys. You can clear the list without selecting anything by pressing Esc (escape key). Note that the list of possible completions might include items that are not valid commands, such as private functions.
Narrowing Completions Shown. You can narrow the list of completions shown by typing a character and then pressing Tab if the Command Window preference Tab key narrows completions is selected. This is particularly useful for large lists. For example, type cam and press Tab to see the possible completions. There is a scroll bar with the list because there are too many completions to be seen at once.

Type p and press Tab again. MATLAB narrows the list, showing only all possible camp completions.

Continue narrowing the list in the same way. For the above example, type o and press Tab to further narrow the list. Press Enter or Return to select an item, which completes the name at the prompt.
Tab completion works for folders and file names in MATLAB functions.
For example, type
edit d:/
and press Tab.
MATLAB displays the list of folders and files in d, from which you can choose one. For example, type
mym
and press Tab.
MATLAB displays
edit d:/mymfiles/
where mymfiles is the only folder on your d drive whose name begins with mym. Continue using tab completion to display and complete folder names or file names until you finish the edit statement.
Tab completion for folders and file names is not supported for functions you write.
Tab completion for class folders (including @-folders), package folders, and file names works the same as for standard folders.
For example, consider the containers package in the matlabroot folder, which is the folder in which MATLAB is installed. The containers package contains a Map @- folder and a Map.m file. The folder structure appears as follows:
+containers\@Map\Map.m
If you type:
edit cont
and press Tab, MATLAB adds characters to cont until MATLAB finds a character that is not common to any names on the MATLAB path. MATLAB displays a list from which to choose, such as the following

If you select containers, add a dot, and then press Tab, MATLAB displays

If you add a dot, press Tab, and scroll down a bit, MATLAB displays

For structures in the current workspace, after the period separator, press Tab. For example, type
mystruct.
and then press Tab to display all fields of mystruct. If you type a structure and include the start of a unique field after the period, pressing Tab completes that structure and field entry.
For example, type
mystruct.n
and press Tab, which completes the entry mystruct.name, where mystruct contains no other fields that begin with n.
Complete the names of Handle Graphics properties using tab completion, as in this example. Here, f is a figure. Type
set(f, 'pap
and press Tab. MATLAB displays

Select a property from the list. For example, type
u
and press Enter. MATLAB completes the property, including the closing quote:
set(f, 'paperunits'
Continue adding to the statement, as in this example:
set(f, 'paperunits', 'c
and press Tab. MATLAB automatically completes the property
set(f, 'paperUnits', 'centimeters'
because centimeters is the only possible completion.
You can use tab completion with MATLAB objects to select from available properties and methods.
For example, create a time series object, tsobj.
tsobj = timeseries
Then enter the object name followed by a period separator (.), such as
tsobj.
Press Tab. MATLAB displays a list of properties and methods for the object, tsobj.

Function hints display allowable input arguments for a function while you enter a statement in the Command Window or Editor. Function hints:
Appear in a temporary pop-up window.
Are useful when you only need a reminder of the syntax for a function.
Provide a link to the reference page for more information.
Are available for all functions provided with MathWorks products. The syntax comes from the function reference page.
Work for functions you create. The syntax comes from the function definition statement (first executable line) in the M-file. The M-file must be on the search path or in the current folder.
Function hints only display input argument syntax. They do not show output argument syntax. To access output argument syntax while using the function hints, clink the More Help link to view the reference page.
These steps illustrate using function hints in the Command Window for the size function.
Type any output arguments and the equal sign. For example, type:
[m]=
Type the function name and the opening (left) parenthesis, and then pause. For example, type:
size(
A yellow pop-up window appears, displaying the syntax options for the function. In this example, the pop-up window indicates that you can enter a single argument, X, or two arguments, X and dim.

Type a variable name for the first input argument. You can type a variable for any argument that appears in bold in the pop-up.
In this example, for the input argument X, type your variable:
my_data
Enter more arguments:
Type a comma after the argument you just entered.
The syntax options in the pop-up window change, based on the argument you just entered.
For this example, the pop-up window now shows only the X,dim option. dim is bold now, because you can enter it.

Type the next input argument. It can be any argument that is bold in the pop-up.
For example, to run size for the third dimension, enter 3 for dim.
Continue entering more input arguments in the same way.
When you finish entering arguments, type the closing (right) parenthesis.
The pop-up window closes.
For an overloaded function name, the syntax for the method includes valid objects of the method currently in the workspace.
MATLAB cannot always determine the appropriate hints correctly. Some allowable arguments may not appear, or could be in plain text when they should be bold.
Click More Help in the pop-up window. MATLAB replaces the pop-up window with a small help window containing the complete reference page for a function. See also Help on Selection and More Help — Specifying Where the Help Displays.
Use function hints along with other methods for getting assistance, including tab completion, the Function Browser, and Help on Selection.
Note When you click anywhere, or move the cursor away from the arguments you are entering, the pop-up window automatically closes. |
Modify your statement while the pop-up window is open, and the function hints change based on your modifications. For example, delete a variable you already typed and that argument appears in the pop-up window.
Click anywhere, or move the cursor away from the arguments you are entering.
Close the pop-up window by pressing Esc (escape).
After closing the pop-up window, reopen it by clearing the arguments you entered and clearing the left parenthesis. Then, enter the left parenthesis and pause to redisplay the hints.
To prevent function hints from appearing, or to show them if they are not appearing, use keyboard preferences.
Select File > Preferences > Keyboard.
In Function hints, select the check boxes for the tools where you want hints to appear. Clear the check boxes for the tools where you do not want hints to appear.
Click OK.
From the Command Window or Editor, display the complete reference page for a function:
Right-click in a function name and select Help on Selection.
The reference page for the function opens in a small help window. The following illustration shows help on selection for the corrcoef function in the Command Window.

Close the small help window by pressing Esc (escape).
Customize the Help on Selection feature:
Specify a preference so that help on selection opens the reference page in the Help browser instead of the small help window. To set the preference, select File > Preferences > Help.
When help on selection opens the reference page in the Help browser, you cannot toggle focus between the reference page and the Command Window or Editor.
Specify the products to look in. See Filter by Product — Specifying Products Used in the Help Browser
Change the small help window font. To change the font, select File > Preferences > Fonts > Custom. The small window uses the HTML proportional text font.
Provides quick access to the syntax for a function and a description of the syntax.
Helps you find the names of functions.
Works in the desktop.
The Function Browser looks for functions using the reference pages for installed MathWorks products.
You cannot use the Function Browser for blocks. Instead use the doc function or the Help browser.
You cannot use the Function Browser to find functions you created or that other users provided. Instead, use Finding Files and Folders.
Open the Function Browser by selecting Help > Function Browser.
In the Command Window or Editor, another way to open it is by
clicking the Browse for functions button,
. To show or hide the
button, see Customizing the Function Browser.

The Function Browser closes when you move the pointer outside of it. To keep the Function Browser open, drag it by the top edge to a different location.
After moving the Function Browser, access it by pressing Shift+F1. Close it by pressing Esc.
Restrict the products the Function Browser looks in by using the Filter by Product option in Help Preferences.
To access the preference, click the product area at the bottom of the Function Browser.
The following illustration shows the filter set to MATLAB and the Signal Processing Toolbox only. The

Find functions by browsing in the list of categories or by typing a search term. You can switch between these two options at any point.
The following illustration shows how you browse for functions by expanding categories of interest.

The following illustration shows results when you search, for example, for filter.

View more information about a function by moving the pointer over a function. A brief description for each of the syntax options displays in a yellow pop-up window.
The pop-up window automatically closes when you move your pointer to a new item in the results list. To keep the pop-up window open, drag it by the top edge to a different location.

Choose a function you want to use and perform any of the following:
Add a function name after the cursor in the Command Window or Editor by double-clicking the name in the Function Browser results list.
Copy and paste the function name into any tool or application by dragging the name from the Function Browser.
Fight-click the function name in the Function Browser to display other options.
Parentheses Indicate Location of Function. For results in products other than MATLAB, the product folder appears in parentheses.
When more than one function in MATLAB has the same name, the folder for the overloaded function appears in parentheses.
For example::
filter is in MATLAB
filter (signal) is in the Signal Processing Toolbox
filter (timeseries) is in the timeseries folder in MATLAB
Highlights in Search Results. In the results, the search term is highlighted in blue.
When a result does not include any blue highlighting, the matching term is not part of the name, syntax, or brief description. The term is somewhere else in the reference page.
Results for a Two-Letter Search Term. For faster performance, when you type only two letters, the Function Browser looks only for exact matches.
View the complete reference page for a function in a small help window by doing either of the following:
From the Function Browser, right-click the function. From the context menu, select Help on Function.
From the Function Browser pop-up window, click More Help.
To open the reference page in the Help browser instead of the small window, set the preference in File > Preferences > Help.
As you type, the Function Browser displays a history of similar search terms that you previously entered, just below the search field. To perform a search again, select an item from the list and press Enter.
To view the entire search history for the current session, press the down arrow key when the search field is empty. To close the history, press Esc (escape).
Show or hide the Browse for functions button
in the Command Window
using Command
Window preferences.
Show or hide the Browse for functions button
in the Editor using Toolbars
preferences for the Editor.
Cange the font used in the Function Browser by selecting File > Preferences > Fonts, The Function Browser uses the desktop text font. The pop-up window uses the HTML proportional text font.
![]() | Entering Statements in the Command Window | Controlling Output in the Command Window | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |