title: Copying part of a matrix to another empty matrix with the same indices
body: <p>I'm trying to copy part of a matrix (matrix 1) in <strong>matlab</strong> to another empty matrix of zeros (matrix 2) so that the section I copy from matrix 1 has the same indices in matrix 2, e.g.</p>
  
  <p>Matrix 1 (mat1):</p>
  
  <pre><code>0 3 0 0 2 4 1 2 6
  1 3 4 2 0 0 0 2 0 
  0 2 6 1 3 6 6 1 1
  0 0 0 2 1 3 3 1 0
  1 4 5 2 3 3 0 0 1
  </code></pre>
  
  <p>Matrix 2 (mat2) <em>desired output</em>:</p>
  
  <pre><code>0 0 0 0 0 0 0 0 0
  0 0 4 2 0 0 0 0 0
  0 0 6 1 3 6 6 0 0
  0 0 0 2 1 3 3 0 0
  0 0 0 0 0 0 0 0 0
  </code></pre>
  
  <p>I've tried something like </p>
  
  <pre><code>mat2([2:4],[3:7]) = mat1([2:4],[3:7]) 
  </code></pre>
  
  <p>but of course it doesn't work... any ideas of an  efficient way to do this? I couldn't find another thread to help with this problem.</p>
  
  <p>Thanks!</p>