| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Paging of Output in the Command Window Formatting and Spacing Numeric Output Number of Characters in Command Window Display |
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 specify keyboard shortcuts for the Cursor Up and Cursor Down actions, for example. For more information on keyboard shortcuts, see Customizing Keyboard Shortcuts.
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
The maximum line length for Command Window display is 25,000 characters. If the output from a statement exceeds this limit, the Command Window truncates the output and displays the following message at the end of the line of output:
Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display.
Clear the Command Window view without clearing the workspace by selecting Clear Command Window from the Edit menu or context menu. A confirmation dialog box appears if the preference for displaying the dialog box is selected.
Afterwards, unless you have changed the keyboard shortcut for it, you can use the up arrow it to recall previous functions from the command history.
For more information, see:
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 MATLAB Editor. 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 Using the Command History Window
The logfile startup option—see Startup Options.
![]() | Assistance While Entering Statements | Finding Text in the Command Window | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |