how can I save a file as .png format?

I have a folder with 20 files in .fig format, how can I save these files in .png format? (they have different names and I want the programm to save the files after some changes.
thanks

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 14 日

1 投票

f=dir('*.fig') % or adsd your folder
for k=1:numel(f)
name=f(k).name;
h=hgload(name);
new_name=strrep(name,'.fig','.png');
saveas(h,new_name);
close
end
David Sanchez
David Sanchez 2014 年 1 月 14 日

0 投票

h=plot(rand(10,1),rand(10,1))
saveas(h,'my_fig','fig'); % your figure is saves as *.fig
% code to print a saved *.fig into *.png
figure_handle = openfig('my_fig.fig');
print(figure_handle,'-dpng','my_fig.png')

1 件のコメント

Mohammad
Mohammad 2014 年 1 月 14 日
thank you, but the files have different names, and some times I dont know the names. what should I put instead my_fid.fig then? can you tell me also how can I open a file with .fig format ( between 20 files in .fig format in a folder), do some changes and save it with the same name but in .png format? Thank you so much.

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

カテゴリ

ヘルプ センター および File ExchangePrinting and Saving についてさらに検索

質問済み:

2014 年 1 月 14 日

回答済み:

2014 年 1 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by