title: Name each variable differently in a loop
body: <p>I have created a .dat file of file names. I want to read into MATLAB each file in that list and give the data a different name. Currently, each iteration just overwrites the last one. </p>
  
  <p>I found that a lot of people give this answer:</p>
  
  <pre><code>for i=1:10
    A{i} = 1:i;
  end
  </code></pre>
  
  <p>However, it isn't working for my problem. Here's what I am doing</p>
  
  <pre><code>flist = fopen('fnames.dat'); % Open the list of file names
  
  nt = 0; % Counter will go up one for each file loaded
  while ~feof(flist) % While end of file has not been reached
      for i = 1:6 % Number of filenames in the .dat file
  
      % For each file
      fname = fgetl(flist); % Reads next line of list, which is the name of the next data file
      disp(fname); % Stores name as string in fname
  
      nt = nt+1; % Time index
  
      % Save data
  
      data{i} = read_mixed_csv(fname, '\t'); % Reads in the CSV file% Open file
      data{i} = data(2:end,:); % Replace header row
  
      end
  end
  </code></pre>
  
  <p>The code runs with no errors, but only one <code>data</code> variable is saved. </p>
  
  <p>My fnames.dat contains this:
  IA_2007_MDA8_O3.csv
  IN_2007_MDA8_O3.csv
  MI_2007_MDA8_O3.csv
  MN_2007_MDA8_O3.csv
  OH_2007_MDA8_O3.csv
  WI_2007_MDA8_O3.csv</p>
  
  <p>If possible, I would really like to name <code>data</code> something more intuitive. Like <code>IA</code> for the first file, <code>IN</code> for the second and so on. Is there any way to do this?</p>