# How to get a special coordinates {x,y} from a matrix in MATHEMATICA.

1. Jan 24, 2012

### 76Ahmad

Hello every one, this question for a mathematics experts...

Suppose we have the matrix

$M = \left| {\begin{array}{cccc} 9 & 6 & 0 & 1 \\ 3 & 7 & 2 & 5 \\ 1 & 0 & 2 & 8 \\ 8 & 8 & 1 & 0 \\ \end{array} } \right|$

and we want to print only the coordinates that equal to 0

for our matrix it will be like that:(let say the raw is X, and the column is Y)

{3,1}
{2,3}
{4,4}

please help
thanks

2. Jan 24, 2012

### Bill Simpson

In[1]:= M={{9,6,0,1},{3,7,2,5},{1,0,2,8},{8,8,1,0}}; Position[M,0]

Out[2]= {{1,3},{3,2},{4,4}}

Mathematica uses {row,column} instead of {column,row}

If you prefer your order for some reason then

In[3]:= Map[Reverse,Position[M,0]]

Out[3]= {{3,1},{2,3},{4,4}}

3. Jan 25, 2012

### 76Ahmad

Thanks Bill

It is work 100%

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook