You can use find to locate nonzero elements in an array, but it requires a little bit of arithmetic. From the documentation:
[row,col] = find(X, ...) returns the row and column indices of the
nonzero entries in the matrix X. This syntax is especially useful when
working with sparse matrices. If X is an N-dimensional array with N >
2, col contains linear indices for the columns. For example, for a
5-by-7-by-3 array X with a nonzero element at X(4,2,3), find returns 4
in row and 16 in col. That is, (7 columns in page 1) + (7 columns in
page 2) + (2 columns in page 3) = 16.
If the matrix M has dimensions a x b x c, then the indices (i,j,k) for some value x are:
[row,col] = find(A==x);
i = row;
j = mod(col,b);
k = ceil(col/b);