title: MATLAB sub2ind using vectors
body: <p>Suppose I have a matrix A</p>
  
  <pre><code>A = magic(5)
  
  17    24     1     8    15
  23     5     7    14    16
   4     6    13    20    22
  10    12    19    21     3
  11    18    25     2     9
  </code></pre>
  
  <p>Now I select a block of this matrix using</p>
  
  <pre><code>A(1:2, 1:2)
  
  17    24
  23     5
  </code></pre>
  
  <p>Now I need the linear index given by (1:2, 1;2) which are (1 2 6 7). Using sub2ind:</p>
  
  <pre><code>sub2ind(size(A),[1:2], [1:2])
  </code></pre>
  
  <p>But this command returns just (1 7) how can I solve this?</p>