MATLAB: How to export figure as png

exporthgexportMATLABpngprintsave figuresaveas

I have the script which creates 3D figure. The only way to save it is
hgsave(graph, [input, output, '\', string{i + 8}, '.png'],'-v7.3');
I tried different ways to save it as png and all failed. It stores only axis.
print(graph,'-dpng',[input,output,'\',string{i +8},'.png']);
saveas(graph, [input, output, '\', string{i + 8}], 'png');
hgexport(graph, [input, output, '\', string{i + 8}, '.png'], hgexport('factorystyle'), 'Format', 'png');

Best Answer

Best option is to use the export_fig function from the file exchange. It actually works out of the box and intuitively (not like the annoying builtin saveas function)
Related Question