How to save AUTOMATICALLY all opened figures (unknown amount) in one .pdf file.

217 ビュー (過去 30 日間)
Yurii Iotov
Yurii Iotov 2019 年 5 月 21 日
コメント済み: Adam Danz 2019 年 5 月 24 日
Hi all
Please, how to save all figures that have been generated by a code (or different codes - so al opened figures) in one pdf file. I found some solution where one need to specify and save manualy all the figures, but I am looking for something fast and automatic.
I have already tried export_fig and SaveFigs from Matlab file exchange but it doesn not work correctly. ( if I am wrong, please show how to use them correctly)
Thanks

採用された回答

Adam Danz
Adam Danz 2019 年 5 月 21 日
編集済み: Adam Danz 2019 年 5 月 21 日
Get handles to all open figures:
figHandles = findall(0,'Type','figure');
Then use export_fig() to save them to a PDF using the -append option.
On the first iteration of the loop you'll need to create the file. On all subsequent iterations of the loops, you'll append the file. Your code may look something like this (you can adapt it to your needs).
% Create filename
fn = tempname(); %in this example, we'll save to a temp directory.
% Save first figure
export_fig(fn, '-pdf', figHandles(1))
% Loop through figures 2:end
for i = 2:numel(figHandles)
export_fig(fn, '-pdf', figHandles(i), '-append')
end
If you want to open the document when you're done,
winopen(fn) %assuming fn is the full path the document
  5 件のコメント
ChrisMat
ChrisMat 2019 年 5 月 24 日
Hey Adam!
If i run export_fig, a window pops up saying: Ghost script not found. Please locate the program.
Could you help me with this one?
thanks!
Christian
Adam Danz
Adam Danz 2019 年 5 月 24 日
Check out the description of the function found here:
When exporting to vector format (pdf & eps), and to bitmap using the painters
renderer, this function requires that ghostscript is installed on your system.
You can download this from:
http://www.ghostscript.com

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by