3.0 | 4 ratings Rate this file 18 Downloads (last 30 days) File Size: 986 Bytes File ID: #37058

clr == clear all; close all; clc;



07 Jun 2012 (Updated )

clr clears your workspace and command window, so you can start fresh.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

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.


This file inspired Cch and Nuke.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
20 Aug 2014 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.


Comment only
31 Oct 2013 Nickolas

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


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

Comment only
19 Jul 2013 Evgeny Pr

Evgeny Pr (view profile)

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

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

12 Jun 2013 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.

07 Jun 2013 Jan Simon

Jan Simon (view profile)

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

Comment only
07 Jun 2013 Jan Simon

Jan Simon (view profile)

20 May 2013 Meiting Liu  
07 Jun 2012 Jan Simon

Jan Simon (view profile)

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.

Comment only
11 Jun 2012

updated Description

Contact us