Entering Commands

Build and run MATLAB® statements


ansMost recent answer
clcClear Command Window
diaryLog Command Window text to file
formatSet Command Window output display format
homeSend cursor home
iskeywordDetermine whether input is MATLAB keyword
moreControl paged output in Command Window
Command WindowSelect the Command Window
Command History WindowOpen Command History window

Examples and How To

Enter Statements in Command Window

Enter individual statements in the Command Window while working in MATLAB.

Format Output

MATLAB displays output in both the Command Window and the Live Editor. You can format the output display using several provided options.

Call Functions

These examples show the syntax to call a MATLAB function.

Continue Long Statements on Multiple Lines

Extend long program lines using ellipses (...).

Rerun Favorite Commands

A MATLAB favorite command is an easy way to run a group of MATLAB commands that you use regularly.

Stop Execution

Stop the execution of a MATLAB command.

Find Functions to Use

Find the name and description of a MathWorks® function from the Command Window or Editor using the Function browser.

Find Text in Command Window or History

Search text currently in the Command Window or Command History Window.

Check Syntax as You Type

Some entries appear in different colors in the Command Window and the Editor to help you identify MATLAB elements. This is known as syntax highlighting.

Write to a Diary File

To keep an activity log of your MATLAB session, use the diary function.


Variable Names

Create valid variable names and avoid potential naming conflicts.

Case and Space Sensitivity

MATLAB code is sensitive to casing, and insensitive to blank spaces except when defining arrays.

Command vs. Function Syntax

If you do not require any outputs from a function, and all of the inputs are character vectors, you can use command syntax. With command syntax, you omit parentheses in the function call and separate the inputs with spaces.

Set Command History Preferences

Specify how often to save automatically the history file and the types of statements to exclude.

Set Command Window Preferences

Specify appearance of Command Window and its output.

Set Keyboard Preferences

Settings for suggestions and completions, function hints, and delimiter matching.


Common Errors When Calling Functions

Troubleshoot error message related to calling functions.