title: Unequivalent loop structure in MATLab
body: <p>I have two versions of code - I wrote the second (more explicit) loop when the first didn't do what I wanted.</p>
  
  <p>Where did I go wrong? I suspect a slicing problem (as in, I'm not correctly slicing the data out)</p>
  
  <p>The first version, which doesn't do what I want, is commented out above the loop:</p>
  
  <pre><code>rBool = false(h.numDirs, h.numTimes, h.numR);
  for d = 1:h.numDirs
      U_first = h.data(d,1,:);
      U_first = U_first{1};
      for t = 2:h.numTimes
          U = h.data(d,t,:);
          U = U{1};
          dU = abs(U-U_first);
          %rBool(d,t,:) = (dU &gt; (smallVal*U_first) | rBool(d,t-1));
          for r=1:h.numR
              rBool(d,t,r) = (dU(r) &gt; (smallVal*U_first(r))| rBool(d,t-1,r));
          end
      end
  end    
  </code></pre>