MATLAB: Global variables not cleared after ‘clear;clc’

global variable

I have a global variable. I run the code for several times. I put 'clear;clc' at the front. Strangely before the global variable is called, it already has a value. However I rerun it, it always has a value before its line is called. What could've happened?

Best Answer

clear by itself only removes variables from the current workspace not the global workspace . You need to
clear global