Save all figures using figure title error
Show older comments
Hello,
I have been using the following code (which I found previously on the site but can't find the author, apologies!) to save all my open figures as a MATLAB figures. The MATLAB figure files are named using each figure's title. I am using version 2021b.
FolderName = pathname; % Folder to save figures
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
ax = findobj(FigHandle, 'type', 'axes');
FigName = ax.Title.String;
set(0, 'CurrentFigure', FigHandle);
savefig(FigHandle, fullfile(FolderName, [FigName '.fig']));
end
I have been using this code for weeks without issue and have encountered this error only recently with the above underlined line FigName = ax.Title.String
ERROR: Intermediate dot '.' indexing produced a comma-separated list with 3 values, but it must produce a single value when followed by subsequent indexing operations.
I need to be able to access the figure's Title, which is a string. If anyone knows how to circumvent this error or another code to access the figure's title, I would greatly appreciate it.
Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!