I am new to MATLAB and was going through some machine learning projects written in MATLAB. Some files start with the following lines:
clear all;
close all;
clc;
I understand that these lines together render a clean work space. Also, that close all
is used to close all figures.
If both the clear all
and clc
are used to clear command window, then what is the difference between the two?
The help
for both are quite thorough.
In short:
clc
- clears the command window
clear all
clears variables, but it also clears a lot of other things from memory, such as breakpoints, persistent variables and cached memory - as your new to Matlab this is probably a bit unclear.
In short: You rarely need to use clear all
- most of the time a simple clear
will be enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With