MATLAB: How to save a figure in multiple formats simultaneously in MATLAB 7.10 (R2010a)

MATLAB

I often find myself saving a figure in multiple formats: a .png to use in presentations, a .eps to use in articles, and a .fig file to be able to back and make modifications. Currently, this means that I must go through the whole save process multiple times with each format, and sometimes I forget to save in all formats after making a modification. It would be nice to be able to select multiple format from a drop-list and have multiple save commands create all files at once.

Best Answer

The ability to do save a figure in mutliple formats simultaneously is not available in MATLAB 7.10 (R2010a).
To work around this issue, you need to create a shortcut in MATLAB. To do that move your mouse pointer to the shortcuts toolbar on the main MATLAB screen. Right click on the toolbar and select the 'New Shortcut' option from the context menu. A text window will open. Please copy the following snippet of code into the text window, and enter an appropriate label for the shortcut, such as "Save Figure to All Formats". Then click on the 'Save' button.
 
% save figure in multiple formats at the same time
filename = inputdlg('Please enter the name for your figures');
extensions = {'eps','fig','png'};
for k = 1:length(extensions)
saveas(gcf, filename{:}, extensions{k})
end
Now each time you click this shortcut, you will be asked for a filename for your files, and the contents of the current MATLAB figure will be saved in the formats specified in 'extensions' cell array to your current directory.
To learn more about INPUTDLG type 'doc inputdlg' on the MATLAB prompt. To learn more about SAVEAS function type 'doc saveas' on the MATLAB prompt, and to learn more about creating MATLAB shortcuts please visit:
You may access the same page locally by typing the following at the MATLAB prompt:
web([docroot,'/techdoc/matlab_env/bq37azl-1.html#br9cxxd'])