Hello.

I have following problem to solve:

There is a square matrix , such like this:

So, let's imagine that - for any reason - I would like to "read" the elements of matrix above in following order:

Could I define some kind of a function, which shows the order described above?

It could relate the sequence of steps to matrix's dimensions as follows:

How could I describe this function? And is there a possibility to define a general description of this type of function for matrices of any order?

Thinking of this, I imagine some kind of 3D coordinate system where the values of arguments determine the positions of points reffering to the order of "reading" of matrix elements.