| MATLAB® | ![]() |
| On this page… |
|---|
Paging of Output in the Command Window Formatting and Spacing Numeric Output |
To display each function within a statement as it executes, run echo on. For details, see the echo reference page.
If you end a statement with a semicolon ( ; ) and then press Enter or Return, the MATLAB® software runs the statement but does not display any output. This is particularly useful when you generate large matrices. For example, running
A = magic(100);
creates A but does not show the resulting matrix in the Command Window.
See also the display reference page.
If output in the Command Window is lengthy, it might not fit within the screen and display too quickly for you to see it without scrolling back to it. To avoid that problem, use the more function to control the paging of output in the Command Window. By default, more is off.
After you type more on, MATLAB displays only a page (a screen full) of output, pauses, and displays
--more--
indicating there is more output to display. Press one of the following keys.
Key | Action |
|---|---|
Enter or Return | To advance to the next line |
Space Bar | To advance to the next page |
q | To stop displaying the output |
You can scroll in the Command Window to see input and output that are no longer in view. As an alternative to scrolling, you can use the up and down arrow keys if the Command Window Accessibility preference is selected.
By default, numeric output in the Command Window is displayed as 5-digit scaled, fixed-point values, called the short format. To change the numeric format of output for the current and future sessions, set the Command Window preference for text display. The text display format affects only how numbers are shown, not how MATLAB computes or saves them.
Use the format function to control the output format of the numeric values displayed in the Command Window. The format you specify applies until you change it or until the end of the session. More advanced alternatives are listed in the "See Also" section of the format reference page.
Here are a few examples of the various formats and the output produced from the following two-element vector x.
x = [4/3 1.2345e-6] format short 1.3333 0.0000 format short e 1.3333e+000 1.2345e-006 format + ++
A complete list and description of available formats is in the reference page for format. For more control over the output format, use the sprintf and fprintf functions.
To control spacing in the output, use the Command Window preference for text display or the format function. Use
format compact
to suppress blank lines, allowing you to view more information in the Command Window. To include the blank lines, which can help make output more readable, use
format loose
Select Clear Command Window from the Edit menu or context menu to clear it. This does not clear the workspace, but only clears the view. Afterwards, you still can use the up arrow key to recall previous functions. A confirmation dialog box appears if you select the preference for it; for more information, see Confirmation Dialogs Preferences.
Use clc to clear the Command Window. Similar to clc is the home function, which moves the prompt to provide a clear screen, but does not clear the text so you can still scroll up to see it.
To print the complete contents of the Command Window, select File > Print. To print only a selection, first make the selection in the Command Window and then select File > Print Selection.
Specify printing options for the Command Window by selecting File > Page Setup. For example, you can print with a header. For more information, see Printing and Page Setup Options for Desktop Tools.
The diary function creates a copy of your session in MATLAB on a disk file, including keyboard input and system responses, but excluding graphics. You can view and edit the resulting text file using any text editor, such as the Editor/Debugger. To create a file on your disk called sept23.out that contains all the functions you enter, as well as output from MATLAB, enter
diary('sept23.out')
To stop recording the session, use
diary('off')
To view the file, run
edit('sept23.out')
There are two other means of viewing session information:
The Command History window contains a log of all functions executed in the current and previous sessions—see Command History Window
The logfile startup option—see Startup Options.
![]() | Controlling Input | Searching in the Command Window | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |