Write a figure to a file automatically in MATLAB

Ed James picture Ed James · Mar 3, 2009 · Viewed 30.8k times · Source

Does anyone know if it's possible to automatically write a figure out to a .eps file in MATLAB?

I'm running a script that produces a large number of graphs, and it'd be nice if I didn't have to manually save each one!

Answer

SilentGhost picture SilentGhost · Mar 3, 2009

print function does that:

Print figure or save to specific file format...

print(filename,formattype) saves the current figure to a file using the specified file format, such as print('BarPlot','-dpng'). If the file name does not include an extension, then print appends the appropriate one.

print(filename,formattype,formatoptions) specifies additional options that are available for some formats.

print prints the current figure to the default printer...