Comments on: Clear Everything! https://blogs.mathworks.com/pick/2013/07/19/clear-everything/?s_tid=feedtopost Jiro and Sean share favorite user-contributed submissions from the File Exchange. Wed, 21 Aug 2013 17:26:16 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Joseph Kirk https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23821 Wed, 21 Aug 2013 17:26:16 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23821 I have a similar shortcut but also add the command:

fclose all;

for cases where there is an error reading a file and it may not have been properly closed.

]]>
By: Jiro Doke https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23726 Wed, 07 Aug 2013 14:47:41 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23726 @Denis,

Just so that you know, you can also make use of the Quick Access Toolbar for those shortcuts that you need all the time. In the screenshot below, the bar that’s just below the toolstrip is the Quick Access Toolbar (which by the way can be moved from the top right of the screen). I have my “ccc” there as well so that I can access it anytime, anywhere.

]]>
By: Dènis Riedijk https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23718 Wed, 07 Aug 2013 02:18:09 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23718 Honestly, whenever I am using something like the clear command I did a little. I can see the use when doing teaching in MATLAB, but otherwise I feel that the need to use clear all is just a sign off bad programming habits. Especially scripts that have it as the starting point.
As for the shortcut functionality: I feel it has lost some of its strength in the latest MATLAB versions because you have to switch tabs now before getting to them.

]]>
By: Sean de Wolski https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23659 Fri, 02 Aug 2013 12:02:42 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23659 @Daniel,

You certainly have a point. I’ll also restart MATLAB the second there is any indication that something has changed one of my default HG properties.

]]>
By: Jiro Doke https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23652 Fri, 26 Jul 2013 16:59:07 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23652 @Daniel,

That made me smile. That’s certainly a perfect way to really reset everything.

I do agree that “ccc” or “clr” will not reset everything (if you take the word “everything” literally). At least for me, it has served its purpose, and I have never had an issue with it.

The main point I wanted to make with this post was that, if people are typing the same commands over and over again, like “clear all; close all; clc”, then they should think of creating a shortcut. Yes, it should probably have documentation, but I was focusing more on the convenience of it, and not on the programming technique used.

]]>
By: Daniel E. Shub https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23651 Fri, 26 Jul 2013 13:02:35 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23651 I find programs like this to be particularly dangerous. You say “I need a quick way to reset everything”, but the result of ccc and clr are a long way from resetting everything (e.g., timers and instruments don’t get deleted and the random number generators don’t get reset). The selections have no error checking and essentially no documentation. I cannot imagine trying to really document exactly what the programs do, which in general is a sign of a bad program.I much prefer to define my ccc shortcut as

!matlab &
exit

which takes a little longer, but puts me in a known state.

]]>
By: Sean de Wolski https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23649 Thu, 25 Jul 2013 13:09:25 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23649 Another thing that I like is for this to work in debug mode and take care of the stack and base workspace:

try
dbquit(‘all’);
end

]]>
By: Julian https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23644 Tue, 23 Jul 2013 16:01:19 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23644 I too have had a short-cut for years for exactly this need. I called it Clean Start (with an empty desktop icon) and it contains the following code:

close all;
delete(timerfindall); % remove any persisting timer objects and their userdata
clear classes;
clc;

I added the timerfindall because I discovered “clear classes” (or “clear all”) is not strong enough to delete these objects. I followed the discussion about this here and on File Exchange with interest, so I have expanded my clear start into a standalone script, adding Stefan’s (https://www.mathworks.com/matlabcentral/fileexchange/authors/287715) useful technique for persisting break-points. Will probably upload to File Exchange in due course.

Yes, it is trivial, I use this loads along with my close-window short-cuts, see https://www.mathworks.com/matlabcentral/fileexchange/39152-apply-standard+-keyboard-shortcuts-keys-to-a-figure-window

]]>
By: Troy Grossarth https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23641 Mon, 22 Jul 2013 15:00:20 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23641 @Shalin, what you are looking for is a tool that I developed called MATLAB State found here: https://www.mathworks.com/matlabcentral/fileexchange/37486-matlab-state.

]]>
By: Mohan https://blogs.mathworks.com/pick/2013/07/19/clear-everything/#comment-23640 Mon, 22 Jul 2013 10:26:53 +0000 https://blogs.mathworks.com/pick/?p=4710#comment-23640 Really useful. Wish to see ‘ccc’ as a default option in the next MATLAB release.

]]>