No products are associated with this question.
"global (main) workspace" I assume/guess you refer to the base workspace.
Try something like
evalin( 'base', 'clearvars *' )
evalin( 'base', 'clear variables' )
in the callback function of the pushbutton. See the documentation on clearvars and on clear
You can try
though I'm not sure that will get everything in the base workspace (doubt it), or just things declared as global (think so). Why do you think you want or need to do this anyway? You can always do clearvars before you run your script or function.