function simpleGUI
x = 1;
quit = false;

mainFig = figure('Visible','on',...
    'Tag','MainFigure',...
    'name','SimpleGui',...
    'NumberTitle','off',...
    'menubar','none',...
    'Color',[.5 .6 .5],...
    'Position',[210,170,660,440]);

set(mainFig,'KeyPressFcn',@keypress_Callback);

PlotButton = uicontrol('Style','PushButton',...
    'Position',[200,43,80,40],...
    'String','Click',...
    'FontSize',18,...
    'Fontweight','b',...
    'Background',[1 1 1],...
    'Foreground',[.1 .1 .1],...
    'Callback',@func_Callback);
    
PlotButton = uicontrol('Style','PushButton',...
    'Position',[300,43,80,40],...
    'String','Close',...
    'FontSize',18,...
    'Fontweight','b',...
    'Background',[.1 .1 .1],...
    'Foreground',[1 1 1],...
    'Callback',@close_Callback);    
    
function func_Callback(source,eventdata)
    disp('button clicked');
    disp(x);
    x = x + 1;
end

function close_Callback(source,eventdata)
    close 'SimpleGui';
    quit = true;
end

function keypress_Callback(source,eventdata)
    key = eventdata.Character;
    disp(key);
    if key == 'q'
        quit = true;
    end
end

  while (~quit)
      pause(1);
  end
  
  close 'SimpleGui';
end