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!
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!
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 asprint('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 or saveas will do the trick.
saveas(fig_handle, 'filename','eps')
print('-deps',fig_handle)
print -deps 1
If you want to specify the output file name, you're better off using saveas.
This was answered in this other question, using the PRINT command. Although that question dealt with making .tiff images, it should be straightforward to modify the code given in those answers to write a .eps.
Suppose, you are generating N numbers of figures in a loop, then you should try the command line:
saveas(gca,sprintf('Figure%02d.pdf',N ));
it produces N figures Figure1.pdf - FigureN.pdf
saveas(gca,sprintf('Figure%02d.eps',N ));
it produces N figures Figure1.eps - FigureN.eps
in place of gca
one can use gcf
also. First command line is a better solution.
Hope this will solve your issue.
© 2022 - 2024 — McMap. All rights reserved.