title: Loading multiple .mat files in the workspace
body: <p>I want to load multiple .mat files (around 500 in number) into my workspace. 
  The files are named as </p>
  
  <pre><code>omni_AP1_trial_1_loc_1.mat 
  omni_AP1_trial_1_loc_2.mat 
  omni_AP1_trial_1_loc_3.mat
  .
  .
  omni_AP1_trial_1_loc_57.mat
  .
  . 
  omni_AP1_trial_10_loc_1.mat 
  omni_AP1_trial_10_loc_2.mat 
  omni_AP1_trial_10_loc_3.mat 
  .
  .
  omni_AP1_trial_10_loc_57.mat
  </code></pre>
  
  <p>I am using the given code : </p>
  
  <pre><code>files_1 = dir('omni_AP1_trial_*_loc_1.mat');
  NumberOfDataset = length(files_1);
  
  for i = 1:NumberOfDataset  
      %get allfiles matching the pattern 'dataset(i)_*'
      files = dir(sprintf('omni_AP1_trial_%d_loc_*.mat',i));
      for j = 1:length(files)
         fprintf('Current file : %s\n',files(j).name)
         a= load(files(j).name);
  
      end
  end
  </code></pre>
  
  <p>During execution even though the fprintf statement shows consecutive files being picked, but the <strong>structure a</strong> holds only the last file that was picked up and the previous file is being overwritten when the loop iterates.</p>
  
  <p>How can I have all the files loaded together in the workspace ? Please help.</p>