Search code examples
matlabmultidimensional-arraymatrix-indexing

Matlab find does not work with high dimensional array?


say A = rand(2,2,2); [a,b,c] = find(A == A(1,2,2))

I got a=1 b=4 c=1

what?


Solution

  • Try this:

    [a,b,c] = ind2sub(size(A), find(A==A(1,2,2)))
    

    Source: find, ind2sub