How to save all the generated figures automatically from a Matlab code to a specified folder in my computer?

12 views (last 30 days)
Hi, I have a script file from which I am expected to generate about 3000 figures through FOR loop iteration (synthetic figures generated through the code of matlab). Now as the outputs are figures , I want them all to save in one folder automatically. (basically i want to create a file path and save all the figures automatically.) It is not possible to save every figure one by one as it will be very time consuming and nearly impossible. Can anyone say how to do it? Thank you in advance very much.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 25 Aug 2018
Edited: KALYAN ACHARJYA on 25 Aug 2018
Inside the loop, after Figure generated, here k loop counts
fig=figure
destination='D:\Kalyan Works\Matlab Work\folder_name\fig';
print([destination,num2str(k),'.dpng']);
close(fig)
It save all figure name as fig1,fig2....
  10 Comments
Jacob Hunter
Jacob Hunter on 13 Apr 2021
@KALYAN ACHARJYA I am able to generate the figures in my folder; however, when I try to open them I get the message "it looks like we don't support this file format." I've tried saving as both '.jpg' and '.png'
Any thoughts on why they can't open? Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Modeling and Prediction 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!