MATLAB: How to clear GUI variables

clear gui variablesgui callback clearMATLAB

Hi,
I'm trying to clear GUI variables. From what I understand, each callback function has its own workspace and separate global workspace. I'd like to clear a specific callback variables with a push button. (Callback function is blockremover_callback, I'd like to reset with a push button).
Thanks!
function clearscreen_Callback(hObject, eventdata, handles)
global xy h binary
%evalin('base','clear h')
clear blockremover_callback
xy = [];
h = [];
binary = [];
%evalin('base','clear all');
cla;

Best Answer

You can clear global variables with clear global.
clear global xy;
clear global h;
clear global binary;
After you clear them, if you need them you need to declare them again:
global xy;
global h;
global binary;
There is no need to clear local variables as they vanish once the function exits.
Related Question