|Desktop Tools and Development Environment|
MATLAB helps you automatically complete the name of a function on the search path, filename, variable, structure, or Handle Graphics property if you type the first few characters and then press the Tab key. To use tab completion, you must have the tab completion preference selected. For details, see Keyboard and Indenting Preferences for the Command Window.
These examples explain how to use tab completion:
Basic Example--Unique Completion
This example illustrates a basic use for tab completion. After creating a variable,
and press Tab. MATLAB automatically completes the name, displaying
Then complete the statement, adding any arguments and 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.
You can also use tab completion anywhere in the line, not just at the beginning. For example, if you type
a = cost
and press Tab, MATLAB completes
Multiple Possible Completions
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
and press Tab. MATLAB displays
The resulting list of possibilities includes the variable name you created,
costs_march, but also includes functions that begin with
cosets from the Communications Toolbox.
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 to select that item to complete 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 select from the list of possible completions using navigation keys such as up and down arrow keys, and Page Up and Page Down. You can clear the list without selecting anything by pressing Escape. Note that the list of possible completions might include items that are not valid commands, such as private functions.
Tab Completion for Directories and Filenames
Tab completion works for directories and filenames in MATLAB functions. For example, type
MATLAB displays the list of directories and files in
d, from which you can choose one. For example, type
mymfiles is the only directory on your
d drive whose name begins with
mym. Continue using tab completion to display and complete directory names or filenames until you finish the
When completing filenames or function names, a name might appear twice in the completion list, once with the a file extension and once without. For example, if you type |
Tab Completion for Structures
For structures, after the period separator, press Tab. For example, type
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
which completes the entry
mystruct contains no other fields that begin with
Tab Completion for Properties
Complete property names using tab completion, as in this graphics example. Here,
f is a figure. Type
Select a property from the list. For example, type
and MATLAB completes the property, including the closing quote.
Continue adding to the statement, as in this example
set(f, 'paperunits', 'c
MATLAB automatically completes the property
set(f, 'paperUnits', 'centimeters'
centimeters is the only possible completion.
|Recalling Previous Lines||Keyboard Shortcuts in the Command Window|
© 1994-2005 The MathWorks, Inc.