MATLAB: Do I get a black square when trying to print or export the image

blackexportimageMATLABprintrenderersavesquare

I get a black square when trying to print or export my image.
Using one of the examples, at the command line I type the following commands
P = peaks(40);
C = del2(P);
surf(P,C)
colormap hot
Once the figure is plotted on the screen in the Figure Dialog, I go to
File->Save As->bmp (or File->Print). I save the file as test.bmp, but when I try to print it, I get a black square.

Best Answer

Sometimes the renderer needs to be forced (depending on the graphics card). You can save the figure from the command line:
print -dbmp -opengl figuregl
In addition there are two other renders:
print -dbmp -zbuffer figurez
print -dbmp -painters figurep
where 'figuregl', 'figurez' and 'figurep' will be .BMP filenames. They will be saved in your current working directory.
This can also be done from the figure user interface:
File -> Page Setup -> Axes and Figures tab -> Figure Renderer (choose from the list box) -> OK, and then Save.