MATLAB: How to save an invisible figure in MATLAB, but make the figure visible when reopened

MATLAB

I have a script that is generating a lot of different figures. The script currently opens a new figure, plots my data, saves the figure, then closes the figure and repeats. The problem I am having is that MATLAB steals focus every time a new figure window is opened, which makes it hard to work at the computer at the same time as my script is running.
The workaround to this problem that I am using is to create the figures invisible. However, this causes another problem: When the figures are saved, they preserve the 'inivisble' state, which means that when I reopen the figures, they remain invisible.
How can I save a figure with the 'visible' property set to 'on', even if the figure itself is currently invisible, without displaying the figure in the process of the save operation?

Best Answer

This is not currently possible in MATLAB. 
As a workaround, please specify 'visible' option when calling 'openfig' to open the figure after it has been saved.
You can also set the "CreateFcn" property of the figure to a function which sets the "Visible" property to on. This allows you to save the figure when invisible but always make it visible when opening it later. 
hFig = figure('Visible', 'off');
plot(1:10)
% Set CreateFcn callback
set(hFig, 'CreateFcn', 'set(gcbo,''Visible'',''on'')');
% Save Fig file
savefig(hFig, 'savedFigure.fig')