I already use the code that I found from MathWorks forum. I wanna save all opened figure (imshow) into spesified folder and name. I have no found error but its result isn't that I want it. The result saves the 7 different name which I want to do but all of them are the last figure, meanwhile I wanna each figure with each name. For an example: Figure 1 is stored with name => resultImage_1.jpg
Figure 2 is stored with name => resultImage_2.jpg
% Specify the folder where the files live.
myFolder = 'D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\imagessss';% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(myFolder) errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder); uiwait(warndlg(errorMessage)); return;end% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(filePattern);for k = 1 : length(theFiles) baseFileName = theFiles(k).name; fullFileName = fullfile(myFolder, baseFileName); fprintf(1, 'Now reading %s\n', fullFileName); % Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
currentImageArray = imread(fullFileName); currentImage{k}=currentImageArray; for i = 1 : 7 outputFolder = 'D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\Hasil Percobaan Lab'; outputFileName = fullfile(outputFolder, ['Hasil Citra Lab_' num2str(i) '.jpg']); imwrite(currentImage{k}, outputFileName); % drawnow; % Force display to update immediately.
endend
Best Answer