MATLAB: Workers aborted when saving surf-figures to disk using parfor

3d plotparforsaveasworker aborted

This code
parfor ii = 1:5
surf(rand(500))
saveas(gcf, ['test_' num2str(ii)], 'eps');
end
causes me the error
>> parfortest
Warning: A worker aborted during execution of the parfor
loop. The parfor loop will now run again on the remaining
workers.
> In parallel_function at 589
In parfortest at 1
Error using parallel_function (line 597)
All workers aborted during execution of the parfor loop.
Error in parfortest (line 1)
parfor ii = 1:5
The client lost connection to lab 2. This might be due to
network problems, or the interactive communicating job
might have errored.
The error occurs only for surfaces above a certain dimension (e.g. surf(rand(5)) is fine). Other 3D-plot as trisurf or plot3 are affected as well while 2D-plots like plot or hist seem to be no problem.
Running this code with R2013b on Mac OS 10.9.3 on a Intel Core 2 Duo

Best Answer

Unfortunately this is likely to be caused by a known bug, the report is here: http://www.mathworks.co.uk/support/bugreports/253188 (I know this refers to 'pcolor' - it's likely that surf has the same problem). Unfortunately, the workaround is not applicable in your case because workers always run '-nodisplay'.
Note that the bug should be fixed in R2014b.