let us consider following program for graphical user interface
function varargout = quadratic(varargin)
% QUADRATIC MATLAB code for quadratic.fig
% QUAD
One of the quick and dirty approaches
myGUI = quadratic;
% ......
% do something or wait until it's done...
% ......
print(myGUI, '-dpng', 'GUIOUT.png'); % save as .png
print(myGUI, '-djpeg', 'GUIOUT.jpg'); % save as .jpg
It will work fine if you only take a screenshot.
However, if you encounter the problem for which the output picture does not have the same size as the figure on your screen (especially when saving as pdf), you will probably have to implement solutions describled in this article.
or even better using fig2file may work for you.