title: Create a matrix using elements of other matrices in MATLAB
body: <p>I have two matrices <code>a</code> and <code>b</code> (with equal number of columns). I want to create a third matrix <code>c</code> using a condition:</p>
  
  <p>For example, I have:</p>
  
  <pre><code>a = [1  2  3  4  1  2  3  4  1  2  3  4; 
       1  1  1  1  2  2  2  2  3  3  3  3]
  
  b = [5  6  7  8  9  10 11 12 13 14 15 16;    
       17 18 19 20 21 22 23 24 25 26 27 28;    
       29 30 31 32 33 34 35 36 37 38 39 40]
  </code></pre>
  
  <p>The condition is: <code>a(2, :) == 2</code>, so the resulting matrix should be:</p>
  
  <pre><code>c = [1 2 3 4;
       2 2 2 2;
       9 10 11 12;
       21 22 23 24;
       33 34 35 36]
  </code></pre>