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:

from

row 1: 1 2 3 
row 2: 4 5 6
row 3: 7 8 9

to

1 4 2 7 5 3 8 6 9

ie write the matrix in a vector along its diagonals from left to top right. any ideas please?


i really need a little more help though:

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

Edit
Report