Development Environment    

Running Programs

Running M-Files

Run M-files, files that contain code in the MATLAB language, the same way that you would run any other MATLAB function. Type the name of the M-file in the Command Window and press Enter or Return. The M-file must be in the MATLAB current directory or on the MATLAB search path--for details, see Search Path.

To display each function in the M-file as it executes, use the Display preference and check Echo on, or use the echo function set to on.

Interrupting a Running Program

You can interrupt a running program by pressing Ctrl+C or Ctrl+Break at any time.

On Windows platforms, you may have to wait until an executing built-in function or MEX-file has finished its operation. On UNIX systems, program execution will terminate immediately.

Running External Programs

The exclamation point character, !, is a shell escape and indicates that the rest of the input line is a command to the operating system. Use it to invoke utilities or run other programs without quitting from MATLAB. On UNIX, for example,

invokes the vi editor for a file named yearlystats.m. After the program completes or you quit the program, the operating system returns control to MATLAB. See the functions unix and dos to run external programs that return results and status.

Opening M-Files

To open an M-file, select the file or function name in the Command Window, and then right-click and select Open Selection from the context window. The M-file opens in the Editor/Debugger.

Function Alternative

Use open or edit to open a file in the Editor. Use type to display the M-file in the Command Window.

Examining Errors

If an error message appears when running an M-file, click the underlined portion of the error message, or position the cursor within the message and press Ctrl+Enter. The offending M-file opens in the Editor, scrolled to the line containing the error.


  Case Sensitivity in Incremental Search Preferences for the Command Window