title: MATLAB: Save image file names to vector
body: <p>I'm doing some sequential image processing and I'm trying to pull out data from each image into a csv file for use in Excel.</p>
  
  <p>I was trying to do this just using a vector for each image variable along with the filename.</p>
  
  <p>However, I'm having trouble making a vector with the filenames within the processing loop. Here's my code.</p>
  
  <pre><code>ImageFolder = C:\Users\X\Documents\MATLAB\Research\Temp
  filePattern = fullfile(ImageFolder, "*.tif');
  tifFiles = dir(filePattern);
  
  for k = 1:length(tifFiles) % Open sequence loop
   baseFileName = tifFiles(k).name;
   fullFileName = fullfile(ImageFolder, baseFileName);
   fprintf(1, 'Now reading %s\n', baseFileName);
   close all % Close images from previous cycle
  
  % skip some lines
  
  Count(k) = size(Areas,1)  &lt;- Works
  Porosity(k) = (sum(Areas) / (size(Istretch,1)*size(Istretch,2)))*100 
  Size(k) = sum(Areas)/Number 
  ImageName(k) = baseFileName  &lt;- This is wrong
  </code></pre>
  
  <p>That just prints out 1st, 2nd, 3rd, etc. letter of each filename as you go through the sequence. I assume there's some simple solution here but I'm not thinking of it. Can anybody clear this up for me?</p>
  
  <p>Thanks!</p>