Matlab:在剧情标题名称下保存jpg文件

时间:2013-05-16 19:56:48

标签: matlab plot save

在MATLAB中,我有一系列简单的图表,标题显示:

  Indiana
  Montana 
  Texas
  Arizona

我需要拍摄这些图并将这些图作为jpg文件保存为名为States的文件夹中的TITLE名称:

 Folder:States
 Indiana.jpg
 Montana.jpg
 Texas.jpg
 Arizona.jpg

谢谢,

阿曼达

1 个答案:

答案 0 :(得分:1)

以下代码将保存所有当前打开的数字,并将其标题作为文件名。

figHandles = get(0,'Children'); % gets the handles to all open figure

for f = figHandles'
    axesHandle = get(f,'Children'); % get the axes for each figure
    titleHandle = get(axesHandle(1),'Title'); % gets the title for the first (or only) axes)
    text = get(titleHandle,'String'); % gets the text in the title
    saveas(f, text, 'jpg') % save the figure with the title as the file name 
end