MATLAB: Obtain row and column indices of non-zero matrix elements

findind2sub

Is there a more efficient way of obtaining the row and column indices of the nonzero elements of a matrix than using the ind2sub and find functions? [I,J] = ind2sub(size(A),find(A));

Best Answer

Of course, there is, use the two output version of find:
[row, col] = find(A)