title: Change for loop index variable inside the loop
body: <p>I need to change my loop variable inside the iteration as I have to access array elements in the loop which is changing w.r.t size inside the loop. </p>
  
  <p>Here is my code snippet:</p>
  
  <pre><code>que=[];
  que=[2,3,4];
  global len;
  len=size(que,2)
  x=4;
  for i=1:len 
      if x&lt;=10
      que(x)= 5;
      len=size(que,2)
      x=x+1;
  
      end
  end
  que
  </code></pre>
  
  <p>Array should print like:</p>
  
  <pre><code>2 3 4 5 5 5 5 5 5 5 
  </code></pre>
  
  <p>But it is printed like this:</p>
  
  <pre><code>2 3 4 5 5 5
  </code></pre>
  
  <p>In Visual C++ the array is calculated correctly and whole array of 10 elements is printed, which increases at run time.</p>
  
  <p>How can I accomplish this in Matlab?</p>