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.
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 .
Inspired: cch - close, clear, home, nuke
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
It does not work!
Hello,
I have noticed that clr command does not work on Matlab 2014b version.
Does someone know why and what's the equivalent command?
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
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!
сlear all, close all, clc
go! go! go! :)))
Oops... All debug break points has been cleared! This is MATLAB style, guy!
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.
I forgot to mention, that "clear all" removes all debugger breakpoints also. And everything, which impedes debugging is a bad programming practize.
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.