obtain row and column indices of non-zero matrix elements

8 views (last 30 days)
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));
  1 Comment
Pablo Ruiz
Pablo Ruiz on 26 Feb 2015
Thanks Guillaume. Is there any (efficient) way to do so without using the find function?

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!