Saving multiple figures all at once
16 views (last 30 days)
Show older comments
I am running a program that generates 50+ figures.
First: Is there a way where I can resize the viewing window for all of the figures without doing it one at a time?
Second: Is there a way I can save them all at once into a PDF? Doing 'File -> Save as...' for each figure gets time consuming.
thanks!
Adrian
0 Comments
Answers (1)
Geoff
on 2 Apr 2012
You'll want to do it in a loop. First, make sure you have stored the handles to your figures in a vector.
figures = [];
% Generate figures
%[your code]
% Resize and output figures
figSize = [21, 29]; % [width, height]
figUnits = 'Centimeters';
for f = 1:numel(figures)
fig = figures[f];
% Resize the figure
set(fig, 'Units', figUnits);
pos = get(fig, 'Position');
pos = [pos(1), pos(4)+figSize(2), pos(3)+figSize(1), pos(4)];
set(fig, 'Position', pos);
% Output the figure
filename = sprintf('Figure%02d.pdf', f);
print( fig, '-dpdf', filename );
end
You can read more about the print command here:
doc print
0 Comments
See Also
Categories
Find more on Printing and Saving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!