Search and help in MATLAB

By Soumya Srivastava and Shruti Datt on September 21, 2017

MATLAB provides various ways in which a user can access help within the software for better understanding of the functions. Similarly, many search options are provided to search text, characters and functions in the software in order to fix errors and avoid bugs. This article focuses on the search function and also discusses options for help and documentation.

Searching function of interest

Search a function in command window  with its description using function browser present in the command window at every new line as shown in image below.

Function Browser
Image 1: Function browser

Enter function name to begin the search. In the present case, MATLAB searches “Pause” (Image 2 a). The function browser displays a list of similar function with their description, on click on the function (Image 2 b).

Searching in Function Browser
Image 2 a): Searching in function browser
Description of Function using Function Browser
Image 2 b): Description of function using function browser

Search text in the command window

“Find dialog box” searches text in the command window. On clicking the drop down button on right of command window title bar (Image below), “find dialog box” opens with options like clear command window, select all, find, print etc.

Drop down Button with options
Image 3: Drop down button with options

On clicking ‘Find’, a new dialog opens (Image below). Enter the text of interest in the dialog box. The search will begin and will be highlighted at the present cursor position in the command window. The searched text highlighted in the command window.

 Find Dialog Box
Image 4: Find dialog box

Quick tip: MATLAB beeps when the search for “find next” reaches the end of the command window or when the search reaches top of command window in case of previous search. MATLAB  continues search even after the beep if the wrap around command is “on”.

Other method to search text in the command window is by ‘Incremental Search’ using keyboard shortcuts. For forward incremental search (from present cursor position to the end of the command window), use Ctrl+Shift+S command  and for backward (from present cursor position to the beginning of the command window) incremental search, use Ctrl+Shift+R command . The incremental search box appears at the right bottom of MATLAB desktop window. When a lower case text is entered in the incremental search box, both lower and upper case text are searched for. But if the text is written in uppercase then only uppercase text for the same will be searched.

For example: on entering “matlab”  in the box, both “matlab” and “MATLAB” will be searched in the command window. But if “MATLAB” is entered then only “MATLAB” will be searched.

Furthermore, use Ctrl+W to complete the partly highlighted text, Ctrl+S to move to next occurrence of text and Ctrl +G to move to last successful search.

Tab compilation

In MATLAB, in order to avoid any typographical errors, type few characters of the word looking out for and press tab. A list of possible matched word or text will appear. Double click on the required option. In image below, first two letters of word to be looked out for are typed that is ‘ta’ and tab (on the keyboard) is pressed. After pressing tab, a list appears as shown in Image 8.

 Use of Tab and List of Possible Functions Using Tab
Image 5: Use of tab and list of possible functions using tab

Hints for function syntax

Many a times, it is impossible for the user to remember all types of arguments in a function. Thus MATLAB provides a hint section wherein on typing the function name and opening the parenthesis (Image below) in the command window, MATLAB opens a toolkit with possible syntax of the function.

Searching functions and list for possible functions
Image 6: Searching functions and list for possible functions

Quick tip: By default, function hints are enabled in MATLAB. To change the  default, follow the following path:

Home tab->Preferences->MATLAB->Keyboard

Diary file or saving MATLAB session

To save a MATLAB session (excluding graphics) on disk file, create a diary file . Create a diary using ‘Diary (on)’ function. Then create a name for the diary with ‘.out’ extension (image below). After completion of the tasks, close the diary using function ‘diary (off)’. MATLAB creates a diary that save whole MATLAB session till ‘diary(off)’. Furthermore, in Image 7 b, MATLAB creates a diary a.out which appears in the current folder.

 Creating Diary File
Image 7 a): Creating diary file
 Display of Diary File in Current Folder
Image 7 b): Display of diary file in current folder

Help and documentation

MATLAB provides inbuilt information about different functions in the documentation section in order to offer help to the user to understand the usage of the functions. To open documentation of a function in command window use the function ‘doc’ and then type name of the function. For example type ‘doc pause’ in command window,  the following page as shown in the image below appears.

Use of doc Function
Image 8: Use of doc function

Furthermore, enter the name of a function in the search box at top right of the MATLAB desktop window  to search it.

Search Box in MATLAB Desktop Window
Image 9: Search box in MATLAB desktop window

The present article presented the basics of MATLAB, with respect to its interface, basic commands, functions, formats and help section. The next article will discuss arrays and matrices in MATLAB including functions and operations applicable on the matrices and arrays.

Soumya Srivastava
Latest posts by Soumya Srivastava (see all)
 

Discuss