Saving multiple figures all at once

9 次查看(过去 30 天)
Adrian
Adrian 2012-4-2
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

回答(1 个)

Geoff
Geoff 2012-4-2
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

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by