MATLAB: How to use GETFRAME on a headless cluster in MATLAB (R2013a)

clusterdisplaygetframeheadlessMATLABnofigurewindow

I have a large number of figures that I need to plot and capture using GETFRAME. Because the computations are time consuming, I have to send the job to a cluster. When I use GETFRAME, I get the following error message:
Error using getframe (line 53)
getframe requires a valid figure window.

Best Answer

To run MATLAB on a headless computer, you would use the following command:
matlab -noFigureWindow
You can then plot your figures and save them as follow:
surf(membrane)
print myFigure.eps
close
However, if you use the command GETFRAME, this latter causes the error
Error using getframe (line 53)
getframe requires a valid figure window.
because the graphics card did not render a figure that GETFRAME can take a screenshot of. Additionally, because workers perform jobs in the background and no display is exported, capturing a snapshot is not possible in the way GETFRAME is implemented.