File Exchange

image thumbnail

clr == clear all; close all; clc;

version 1.1.0.0 (986 Bytes) by Brenden Epps
clr clears your workspace and command window, so you can start fresh.

1 Download

Updated 11 Jun 2012

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

clr performs: clear all; close all; clc;

This clears your workspace, closes all figures, and clears command window.

clr is a quick way to "reset" Matlab.

The only point of this function is to save key strokes. If you use Matlab often and you value your time, then this function may appeal to you.

Cite As

Brenden Epps (2021). clr == clear all; close all; clc; (https://www.mathworks.com/matlabcentral/fileexchange/37058-clr-clear-all-close-all-clc), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (11)

Tomislav Covic

It does not work!

Yuting Ren

Sami Goussi

Hello,

I have noticed that clr command does not work on Matlab 2014b version.
Does someone know why and what's the equivalent command?

Jonathan Suever

I have uploaded a version that I use that does a decent amount of error checking prior to running the commands to ensure that there are no issues. It also incorporates fixes for a lot of the questions and concerns voiced here.

http://www.mathworks.com/matlabcentral/fileexchange/47609-nuke

Nickolas

You could add this to your code to clear the Command History as well:

com.mathworks.mlservices.MLCommandHistoryServices.removeAll;

Just thought this was a nice thing to add to it. Thanks!

Evgeny Pr

сlear all, close all, clc
go! go! go! :)))

Oops... All debug break points has been cleared! This is MATLAB style, guy!

William

This is a great function for saving time when you are doing trial-and-error type coding with figures and need to run an m file over and over again as you tweak it. i actually had a script version of this named 'gameover' but 'clr' is nice and curt. this function won't appeal to users like Jan that are doing debugging.

Jan

I forgot to mention, that "clear all" removes all debugger breakpoints also. And everything, which impedes debugging is a bad programming practize.

Jan

Meiting Liu

Jan

You forgot to mention that "clear('all')" removes all loaded functions from the memory and that reloading them is very time-consuming. Because all PERSISTENT variables are cleared also, function may need a new initialization also.
clear('all') is useful, if you have modified all(!) M-files during a program runs and you need to use the new functions - a very rare situation.
In addition the result of clear('all') can be surprising, if there is a variable called "all" in the workspace.
pack() and fclose('all') could be considered also. A situation where I need a reset is a crashing CloseRequestFcn, which prevent the regular removing of a window. Then close('all') will fail also and a more powerful method is required.
My opinion is, that this function is to brute for standard cases and to weak for hard cases.

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: cch - close, clear, home, nuke

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!