R function in MATA?

#1
Hello,

I have the following question on a R function which a want to use in MATA (the matrix programming language in STATA)

In R you have the which() function, which works as follows. Suppose you have a matrix Z:

0 0 0
1 0 0
0 1 0
99 99 1
99 99 99
99 99 99

then using which (Z==99, arr.ind = T)

finds entries with Z=99 and returns an array with coordinates as follows:

row col
4 1
5 1
6 1
4 2
5 2
6 2
5 3
6 3

Does anyone know a related function in MATA?

regards Alex