2.1. The MATLAB Development Environment

The MATLAB integrated development environment (IDE) is conducive to rapid program development. It is shown in figure The MATLAB integrated development environment and includes the following.

MATLAB Desktop:

The desktop typically contains at least five subwindows: the Command Window, the Workspace Browser, the Current Directory Window, the Command History Window, and one or more Figure Windows, which are visible when displaying plots or images. The Layout menu on the HOME tab lists other subwindows that users may wish to try.

MATLAB Editor:

The editor is used to create and edit M-files. It includes a number of useful functions for saving, viewing, and debugging M-files.

Help System:

The Help System includes the Help Browser, which displays HTML documents and contains a number of search and display options.

The MATLAB integrated development environment

Fig. 2.1 The MATLAB integrated development environment

2.1.1. Using the IDE

The interaction between the Command Window, Workspace Browser, Command History Window, and the Editor make a convenient environment for software development.

  • In the Command Window, users may interactively type commands. Simple calculations may be entered using only the command window. It is also nice for testing commands and syntax before adding those commands to a file in the editor.

    As demonstrated in Command Window Calculator, the prompt for entering commands is >>. Several examples in this book show this prompt to indicate that the demonstrated commands may be entered in the Command Window.

  • The value and size of variables can be viewed either from the Command Window or the Workspace Browser.

  • The Command History Window shows previous commands entered. Click on a previously entered command with the mouse. Hold down the shift key and use the arrow keys to select multiple previous commands. With commands selected, press the F9 keyboard key to run the selected commands. Commands from the Command Window and the Editor may also be highlighted with the mouse and run by pressing F9.

  • In the Editor, users type code into scripts and functions so that they will be saved for future use.

    When writing a script file, commands in the script can be run as though they were typed in the command window.

  • The debugger is used to set breakpoints that stop the execution at set places. With the execution stopped, a user can use the command window to determine what changes are needed to fix a problem.

  • The profiler allows for improving the performance of larger programs by measuring where the program spends the most time.

2.1.2. How to get help

MATLAB provides an extensive set of commands and functions to ease the programmer’s task. So finding documentation is critical to being successful. MATLAB provides three simple mechanisms to find the information that you need.

  1. Use the help tool from the Command Window. For example, to learn about the disp function type, help disp.

  2. Near the upper right corner of the MATLAB development environment is an input box labeled Search Documentation. Type anything that you want more information about in this box and select from the list of available documents. The documentation is displayed in a separate document browser window. The information found will usually be more detailed than that given by the help tool from the Command Window. It will often include useful examples. The doc command in the Command Window also launches the document browser and displays the same information.

  3. The same documentation available from the built-in search tool can be found on MathWorks’ web pages. Using your web browser and favorite Internet search engine, just add the word ’matlab’ to what you are looking for.

2.1.3. Options for using MATLAB

  • Use K-State’s MATLAB floating licenses from campus lab computers.

  • A student license is fairly affordable. With a student license, you also have access to MATLAB Online and MATLAB Mobile. MATLAB Online allows access to MATLAB from any Internet connected computer.

These options will be discussed in class.