How to clear the command window in MATLAB?

How to clear the command window in MATLAB?

Posted by

Matrix Laboratory or MATLAB is a programming language and environment for numerical computations developed by MathWorks. It is an important software used by millions of engineers and scientists for applications as diverse as machine learning, deep learning, signal processing, image processing, video processing, signal systems, control systems, computational biology, and many more.

Matlab includes Simulink – used primarily for graphics programming – and two types of editors. It is a practical tool with simple operation that makes working in a particular area much easier. With clc, the command window can be emptied every time the user executes their code.

The MATLAB command window explained.

The command window is always open by default and allows the user to enter and run individual commands on the command line (>>) and view the results. In the following example, the value 25 should be stored in variable A and then executed in the next line.

Assigning and displaying the value 25 to variable A in the command window

The normal or direct editor is used when a few lines of code need to be written. In this case, the command window is not used specifically for execution.

However, it is an important tool for entering data, running a particular Matlab function, and running .m or .mlx files. For .m files (normal editor) the output is also displayed in the command window, while for .mlx files (live script editor) the command window is only used to receive input, the output is displayed in the editor itself.

Also read : What is Tmux and how do you use it ?

The command to clear the command window is clc. This command can be used in three ways: directly, with the standard script editor or live.


Just before the prompt, type clc into the command window and press Enter.

Control window for clc control

This clears the command window.

Command window after clc command

Using the editor (standard and live scenarios)

If you are coding in a normal editor, the clc command can be written at the beginning of the code so that each time you execute and re-execute the code, the command window is emptied. This avoids having to clean up the command window using the direct method mentioned above to run the program every time.

Example: Editor without CLC

Here is an example of an editor without the clc command.

Here, the command window is not cleared with every program start.

Example: CLC Editor-in-Chief

Here is an example of an editor using the clc command.

You can see here that the command window is emptied each time the code is executed.

As in the normal editor, the clc command is used in the same way in the real-time script editor.

The clc command only clears the command window. A value stored in the work area remains unprocessed. This means that if the value A = 25 is stored in the worksheet, the value of A will be stored as 25 even after the command window is cleared.

Also read : What is an M3U file? How do you open it?

Creative nerd, table tennis player, brilliant reader and graduate engineer.

Related Tags:

Feedback,matlab clear command historyhow to clear workspace in matlabclear command windowmatlab clear memoryhow to delete a command line in matlabclose all command in matlab,People also search for,matlab clear command history,how to clear workspace in matlab,clear command window,matlab clear memory,how to delete a command line in matlab,close all command in matlab,to determine whether an input is matlab keyword, command is?,how to delete in matlab command window

Leave a Reply

Your email address will not be published. Required fields are marked *