在 MATLAB 中,我有一组简单的绘图,标题显示:
Indiana
Montana
Texas
Arizona
我需要将这些图按 TITLE 名称保存为 jpg 文件,保存在名为 States 的文件夹中:
Folder:States
Indiana.jpg
Montana.jpg
Texas.jpg
Arizona.jpg
谢谢,
阿曼达
以下代码将保存所有当前打开的图形,并将其标题作为文件名。
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