title: transforming a matrix into a vector along its diagonals
body: <p>im not not a programmer, i just need to solve something numerically in matlab.
  i need a function to make the following transformation for any square matrix:</p>
  
  <p>from</p>
  
  <pre><code>row 1: 1 2 3 
  row 2: 4 5 6
  row 3: 7 8 9
  </code></pre>
  
  <p>to</p>
  
  <pre><code>1 4 2 7 5 3 8 6 9
  </code></pre>
  
  <p>ie write the matrix in a vector along its diagonals from left to top right.
  any ideas please?</p>
  
  <hr>
  
  <p>i really need a little more help though:</p>
  
  <p>say the matrix that we have transformed into the vector, has entries denoted by M(i,j), where i are rows and j columns. now i need to be able to find out from a position in the vector, the original position in the matrix, i.e say if its 3rd entry in the vector, i need a function that would give me i=1 j=2. any ideas please? im really stuck on this:( thanks</p>