Orion42 ~IT made easy~

Giving feedback, alpha testing and solving common problems with out of the box and lateral thinking


[Matlab] How to quickly clean the workspace

How many times did it happen to you to close all the open window, remove the variable in the workspace and then clear the screen to start all over again from scratch? If this is the case, then just a few lines of code can save you a lot of time in the future.

Create a new .m file and copy those lines:

close all;    % Close all open figures 
clear;        % Clear all remove also break points
clear global; % Clear also global variables
clc;          % Clean the screen

with the comments in the code explaining what each command does.

Then save the file with a short name you easily remember – I choose “cc” (but t his name is also a built-in function that I do not use in one of the libraries). I suggest to put it in a folder where to save your other custom script. This folder can then be¬†added it to the Matlab Path (Home tab > Set Path) so it will be automatically searched for form the command line.


Your email address will not be published. Required fields are marked *

Skip to content