MATLAB: Is it possible to create multiple figures in background such that it does not steal focus in MATLAB 7.8 (R2009a)

invisbleMATLABvisible

I would like to have a plotting script which will create hundreds of plots. Immediately after the figure is created I would like to save it as a MATLAB Figure file format. Each time the figure gets created or updated it steals focus from what I am doing on my computer. I would like MATLAB to create this figures in background or invisibly such that it does not steal focus.

Best Answer

The ability to create figures in background is not available in MATLAB 7.8 (R2009a).
To workaround this issue, use any of the following workarounds:
1. Create the figure with 'Visible' property to be 'off' and save the figure. While loading the figure change this property to 'on'. For instance:
h=figure('Visible','off');
plot(1:10)
hgsave(h,'firstfigure.fig');
close(h)
prop.Visible='on';
[h1,old_prop]=hgload('firstfigure.fig',prop);
2. Create the figure with 'Visible' property to be 'off' and save the figure. Then set the figure's 'CreateFcn' to set the 'Visible' property back to 'on'. This will only get implemented next time the same figure is created and will have no effect on the current figure as it is already created. For instance:
h = figure('Visible','off');
set(h,'CreateFcn','set(h,''Visible'',''on'')');
plot(1:10);
hgsave(h,'secondfigure.fig');
close(h);
hgload('secondfigure.fig');