The variables are undefined because your graphic objects have lost their handles, because those handles are beyond the scope of your current process.
You should set the script to be the callback function for the pushbutton assign tags (Tag property of your graphic objects) to your graphic objects so that you can assign them a handle in your script.
for example if I had an edit field that I assigned the tag 'edit1' in GUIDE,
then in your callback function for your pushbutton I can retrieve its properties by:
found_edit = findobj(gcf,'Tag','edit1');
I dont prefer using guide, so usually when I create my uicontrols I assign them a tag with:
edit1 = uicontrol('Style','edit','Tag','edit1')
then I can refer back to them in any function I want, so as long the figure and it exists.