Save all the plots
古いコメントを表示
Each time I run my code it produces 100 figures. So, I have to waste my time and save each one of them. Is there a command that can do that work for me by saving all the figures at once?
1 件のコメント
Hira
2022 年 9 月 27 日
m=1;
title("S31 Plot Measurement Number ("+m+")")
xlabel('Delay')
ylabel('Mag(S31)')
saveas(gcf,"S31_plot_"+name+"_Measurement_No_"+m+".fig")
close(gcf)
m=m+1;
採用された回答
その他の回答 (3 件)
Missed a make current step: set(0, 'CurrentFigure', figureHandle)
FolderName = tempdir; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = num2str(get(FigHandle, 'Number'));
set(0, 'CurrentFigure', FigHandle);
savefig(fullfile(FolderName, [FigName '.fig']));
end
5 件のコメント
Tanziha Mahjabin
2020 年 2 月 17 日
Hi,
i have already saved figures in a folder. how can i make a gif in matlab combining all of them?
manvir kaur
2022 年 6 月 6 日
i have same issue, this code works perfectly but i want to save figures in png format. So how to do that. Thanks
Nabil Mederbel
2022 年 6 月 11 日
Hi guys,
I tried to save figures with '.eps' format ...didnt work.
any idea ? thx
José Ángel Sevillano Caraballo
2024 年 6 月 10 日
This worked for '.png' format, it should work for whatever format you want.
FolderName = tempdir; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = num2str(get(FigHandle, 'Number'));
set(0, 'CurrentFigure', FigHandle);
saveas(FigHandle,fullfile(FolderName, [FigName '.png'])); %Specify format for the figure
end
Tanveer
2022 年 9 月 18 日
4 投票
FolderName = 'xx'; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = ['Fig' num2str(iFig)];
savefig(FigHandle, fullfile(FolderName, [FigName '.fig']));
saveas(FigHandle, fullfile(FolderName, [FigName '.png']));
% saveas(FigHandle,filename,formattype)
end
Mehri Mehrnia
2022 年 8 月 3 日
0 投票
Based on the answers, it means there is no 1 line of code which can save all open plots?
1 件のコメント
Hira
2022 年 9 月 27 日
m=1;
title("S31 Plot Measurement Number ("+m+")")
xlabel('Delay')
ylabel('Mag(S31)')
saveas(gcf,"S31_plot_"+name+"_Measurement_No_"+m+".fig")
close(gcf)
m=m+1;
カテゴリ
ヘルプ センター および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!