title: save in for loop matlab
body: <p>I am trying to save variables in a for loop. The following new variable can be created:</p>
  
  <pre><code>eval(['C' num2str(j) '=B']);
  </code></pre>
  
  <p>But I get an error while using this to save the variable by the following command :</p>
  
  <pre><code>save([dataDir, files(j).name],eval(['C' num2str(j) '=B']),'-append')
  </code></pre>
  
  <p>The error is : (Error: The expression to the left of the equals sign is not a valid target for an assignment.).</p>
  
  <p>I wonder what is wrong with my approach and how can I save the changing variable name in changing file name in a for loop.</p>
  
  <p>I will greatly appreciate your assistance.</p>