Script to save matlab figures to a specified direc

2020-06-12 22:13发布

Suppose I have several figures open in matlab. I would like some function I can call, e.g save_all_figures_to_directory('dir_name'), that would iterate over all figures and save them to the specified folder. How do I do this?

1条回答
家丑人穷心不美
2楼-- · 2020-06-12 23:00

You can use the Matlab function findobj:

function save_all_figures_to_directory(dir_name)
figlist=findobj('type','figure');
for i=1:numel(figlist)
    saveas(figlist(i),fullfile(dir_name,['figure' num2str(figlist(i)) '.fig']));
end
end
查看更多
登录 后发表回答