FUNCTION REFERENCE
Save a figure to a file.
Save a figure to a file.
Syntax
print(filename, '-dformat')Syntax
print(fig, filename, '-dformat', '-rdpi')Syntax
print -dpng filenameWrites the current (or given) figure: -dpng, -djpeg, -dtiff, -dpdf and -dsvg through exportgraphics, -depsc through saveas. The device's extension is added when the filename has none; a filename with another extension is kept as given. Without -d the extension picks the format (default PNG). -rN sets the resolution (-r0 = 96 dpi); -fN selects figure N; -painters, -opengl, -vector, -image, -noui, -bestfit, -fillpage and -loose are accepted and ignored.
Example
plot(1:3); print('-dpng', 'plot.png') % writes plot.pngDifferences from MATLAB: printing to a printer, the clipboard and other devices (-dbmp, -dmeta, -dps ...) is not supported yet; PDF output is the tight figure, not a full page. Needs a build with the plot-export feature (on in the desktop build).
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.