3.0

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

clr == clear all; close all; clc;

by

 

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
Description

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.

Acknowledgements

This file inspired Cch.

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 (7)
31 Oct 2013 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!

19 Jul 2013 Evgeny Pr

с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

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

07 Jun 2013 Jan Simon  
20 May 2013 Meiting Liu  
07 Jun 2012 Jan Simon

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.

Updates
11 Jun 2012

updated Description

Contact us