将Matlab图形保存到指定目录的脚本 [英] Script to save matlab figures to a specified directory
本文介绍了将Matlab图形保存到指定目录的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我在matlab中打开了几个数字.我想要一些可以调用的函数,例如save_all_figures_to_directory('dir_name')
,它将遍历所有图形并将它们保存到指定的文件夹中.我该怎么做?
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?
推荐答案
您可以使用Matlab函数 findobj
:
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
这篇关于将Matlab图形保存到指定目录的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文