Saving multiple matlab figures as per their title
    14 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hey all,
I am currently using this code to save all the opened Matlab figures. The code saves figures as per numbeR (1,2,3.fig). Instead of numbering, i want to save the files as per title (T100_edot0.01.fig T200_edot0.02.Fig and so on)
FolderName = 'C:\\Bergström\Data_generated_Bergström';   % 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
Many thanks in advance
0 件のコメント
回答 (2 件)
  Paresh yeole
      
 2020 年 6 月 9 日
        t= get(gca,'title');
FigName = get(t,'string');
This should do the work.
0 件のコメント
  Ameer Hamza
      
      
 2020 年 6 月 10 日
        Figure does not have titles, I guess you want to get the axes title. An alternative to Paresh solution is following using OOP syntax
FolderName = 'C:\\Bergström\Data_generated_Bergström';   % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
  FigHandle = FigList(iFig);
  ax = findobj(FigHandle, 'type', 'axes');
  FigName   = ax.Title.String;
  savefig(FigHandle, fullfile(FolderName, [FigName '.fig'])); % in this case, no need to use set(0, 'CurrentFigure', FigHandle);
end
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


