title: Variable appears to change size on every loop iteration - what?
body: <p>When writing the following Matlab code:</p>
  
  <pre><code>for ii=1:n
      x(ii) = foo( ii ); % foo is some function of ii that cannot be vectorized.
  end
  </code></pre>
  
  <p>I get the following <a href="http://www.mathworks.com/help/matlab/ref/mlint.html" rel="nofollow noreferrer">m-lint</a> warning:</p>
  
  <blockquote>
    <p>The variable <code>x</code> appears to change size on every loop iteration</p>
  </blockquote>
  
  <p>My question:</p>
  
  <ol>
  <li>What does that warning mean?  </li>
  <li>Why is changing variable size every iteration is a bad thing?  </li>
  <li>How can this problem be solved?</li>
  </ol>
  
  <hr>
  
  <p>This question is not duplicate of <a href="https://stackoverflow.com/questions/5171356">this one</a>, since it deals with more general aspects of preallocation, rather a specific instance of it.</p>