save images in a new folder

1 view (last 30 days)
I am using the below subroutine inside for loop to save images during every itertaion. Here, I would like to save the images in new folder. Please help me with this...
if (f>=1) && (f<=9)
saveas(gcf, sprintf('S0000%d', f), 'bmp')
elseif (f>=10) && (f<=99)
saveas(gcf, sprintf('S000%d', f), 'bmp');
elseif (f>=100) && (f<=999)
saveas(gcf, sprintf('S00%d', f), 'bmp');
saveas(gcf, sprintf('S0%d', f), 'bmp');
Turbulence Analysis
Turbulence Analysis on 27 Sep 2020
Thanks it worked perfectly..
Furthermore, regarding my previous query on "having two colorbars in the contours for the images read in .im7 format". I have sent the .im7 files and loadvec function as per your request. Is .im7 readable now ???

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 26 Sep 2020
Do it this way:
folder = pwd % Wherever you want...
for k = 1 : 1234
thisBaseFileName = sprintf('S%4.4d.png', k);
fullFileName = fullfile(thisBaseFileName);
fprintf('Saving %s\n', fullFileName);
% saveas() of exportgraphics()

More Answers (1)

Mario Malic
Mario Malic on 26 Sep 2020
saveas(gcf, sprintf('/folder/S0000%d.bmp', f))
Mario Malic
Mario Malic on 26 Sep 2020
No, /folder/ is, but use Image Analyst's solution, it's much better than what you have.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!