Matlab

How to Clear Command History in MATLAB Command Line

MATLAB is a powerful computing tool that makes it possible for you to plot and visualize your data through MATLAB programming. It provided users the opportunity to either execute the code through the main script file or use its command-line windows to execute any statement with ease. This is the reason why beginners prefer to use the MATLAB command line instead of a script file to better understand each line of code with ease. However, with too many commands executed on the command line, you must clear them to avoid clutter and confusion.

Follow this guide to find out how to clear command history in the MATLAB command line.

How to Clear Command History in MATLAB Command Line?

The clc is the command used in MATLAB to clear the command history of the command line. It clears the command history and resets the cursor to the home position, thus, making it easy for you to execute the commands from the start.

For example, if you have executed multiple commands in the MATLAB command line and want to clear them all, you simply have to run the clc command to clear them in no time.

As soon as you execute the clc command, the command-line history will be cleared.

Note: Using the clc command will only remove the command-line history, the variables stored in the workspace will not be removed.

If you want to clear the workspace variables, you can use the clear all or clear command. While to close the plots in MATLAB, close all commands are used.

Note: You must make a habit of using clc, clear all, and close all at the beginning of your code for an effective code. Professional programmers widely used these commands in their codes.

Conclusion

Clearing the command-line history is important in MATLAB that helps avoid clutter and confusion, prevent errors, and start fresh. The clc command is used to clear the MATLAB command window history, however, if a user wants to clear workspace history, he/she should use the clear or clear all command, while for closing plots, he/she should go with executing the close all command in the command window of the MATLAB.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.