0
$\begingroup$

In this post, it is discussed how to find the positions in a list such that a given criterion is satisfied.

But how does this generalize to lists of $n$ dimensions? Let us take for example the case of a 3D matrix:

mat = Table[i*j*k, {i, 1, 3}, {j, 1, 3}, {k, 1, 3}];

I want to find the positions where the value is, for example, larger than 15. So I want the result to be

{{2, 3, 3}, {3, 2, 3}, {3, 3, 2}, {3, 3, 3}}
$\endgroup$
  • 3
    $\begingroup$ You could have tried the method in the first answer yourself to answer your own question: Position[Table[i*j*k, {i, 1, 3}, {j, 1, 3}, {k, 1, 3}], x_ /; x > 15] or Position[Table[i*j*k, {i, 1, 3}, {j, 1, 3}, {k, 1, 3}], _?(# > 15 &)] $\endgroup$ – J. M.'s ennui May 4 '20 at 15:02

Browse other questions tagged or ask your own question.