title: MATLAB: comparing all elements of two arrays
body: <p>I have two matrices in MATLAB lets say <code>arr1</code> and <code>arr2</code> of size 1000*1000 each. I want to compare their elements and save the comparison in a result matrix <code>resarr</code> which is also 1000*1000 such that for each element:</p>
  
  <ul>
  <li>if the element in <code>arr1</code> is bigger than the one in <code>arr2</code>, place the value 1 in the result</li>
  <li>if the element in <code>arr2</code> is bigger, store the value 2</li>
  </ul>
  
  <p>but I don't want to do this with for loops because that is slower. How can I do this?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong>
  Also if I wanted to store different RGB values in a 1000*1000*3 result matrix, depending on the comparison of <code>arr1</code> and <code>arr2</code>, could that be done without slow loops?</p>
  
  <p>For example store (255,0,0) if <code>arr1</code> is larger and (0,255,0) if <code>arr2</code> is larger</p>