Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In MatLab matrices, the indices are as follows:

(1,1) (1,2) (1,3)
(2,1) (2,2) (2,3)
(3,1) (3,2) (3,3)

This is an example 3x3 matrix. In corresponding cartesian coordinate system, the representation would be:

(-1,1) (0,1) (1,1)
(-1,0) (0,0) (1,0)
(-1,1) (0,-1) (1,-1)

Say, I have any square matrix with dimension-N, where N is odd. I need a generic transformation matrix such that I can get a vector as cartesian coordinates from matrix indices. Does such a function already exist? How should I go ahead in implementing this?


share|cite|improve this question
I think your $(-1,1)$ on the second matrix, first column, third row should be $(-1,-1)$. – a.r. Jan 19 '12 at 4:21

The transformation of indices is the following:

$$ (x,y) = f(i,j) = \left( j-\frac{n+1}{2} ,-i + \frac{n+1}{2}\right) \ . $$

Here $i$ is the index for the rows, $j$ the one for the columns and $n$ the order of your square matrix.

share|cite|improve this answer

Interchange indices $i$ and $j$ in initial matrix, then flip it upside down to get the same orientation like a usual coordinate system and then subtract $(2,2)$ or $(\frac{n+1}{2},\frac{n+1}{2})$ in general to shift the center.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.