title: The for loop doesn't iterate
body: <p>In MATLAB the following <code>for</code> loop:</p>
  
  <pre><code>for i = [1:100]' 
      %'// Do something, such as disp(i)
  end
  </code></pre>
  
  <p>isn't apparently really implemented by iteration, rather <code>i</code> becomes the matrix [1 2 3 ... 100] and the "loop" is only executed once on this matrix <code>i</code>. You can verify this by printing the value of <code>i</code> or other tracking information. Only a single pass is made through the loop.</p>
  
  <p>Is it possible to force MATLAB to do genuine looping? The reason I ask is that the above approach is fine for many cases but much more painful when you have nested loops that need to run. </p>
  
  <p><strong>Example</strong>:<br/>
  The following code won't do what you would expect if you thought you were getting actual iteration over a loop:</p>
  
  <pre><code>for i = outlier
      data(i) = median(data(i-100:i+100))
  end
  </code></pre>
  
  <p>One would expect at each outlier index this would replace data(i) with the median of the data from i-100 to i+100, but it doesn't. In fact, the median returns a single value computed on a conglomerate of all the ranges you cared about, and every data(i) point is replaced with that single value.</p>