title: How to save multiple images in .mat file In MATLAB environment
body: <p>Below is my code that i have tried but it reads the images from the folder but when i am
  trying to store the all image  to mat file but it store the last array in the mat file</p>
  
  <pre><code>myFolder = 'C:\Users\protocol\Desktop\Finger-Print';
  if ~isdir(myFolder)
    errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
    uiwait(warndlg(errorMessage));
    return;
  end
  filePattern = fullfile(myFolder, '*.jpg');
  jpegFiles = dir(filePattern);
  for k = 1:length(jpegFiles)
    baseFileName = jpegFiles(k).name;
    fullFileName = fullfile(myFolder, baseFileName);
    fprintf(1, 'Now reading %s\n', fullFileName);
    imageArray = imread(fullFileName);
  
    save db2.mat imageArray; here it save the last image array to db2.mat file
  
    imshow(imageArray);  % Display image.
    drawnow; % Force display to update immediately.
  end
  </code></pre>
  
  <p>but but i want to store multiple images in a mat file so that i can load this file later
  and access the images</p>