MATLAB: Save all the plots

plotsavesave plot

Each time I run my code it produces 100 figures. So, I have to waste my time and save each one of them. Is there a command that can do that work for me by saving all the figures at once?

Best Answer

No, there is no such command. But it is easy to write one:
FolderName = tempdir; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = get(FigHandle, 'Name');
savefig(FigHandle, fullfile(FolderName, FigName, '.fig'));
end
Adjust the FigName to your needs.