0

How to find the indices of rows without any zero in a matrix?

Example:

A = [
       14  0  6  9  8  17
       85 14  1  3  0  99
       0   0  0  0  0   0 
       29  4  5  8  7  46
       0   0  0  0  0   0
       17  0  5  0  0  49
]

the desired result :

V =[4]
bzak
  • 563
  • 1
  • 8
  • 21
  • 1
    @Adiel: you should post that as an answer. btw I would be more specific in using: `find(all(A ~= 0, 2))` – Amro Nov 09 '14 at 13:55
  • 1
    You may consider merging this question with your [previous](http://stackoverflow.com/questions/26827975/how-to-find-the-indices-of-nonzero-rows-in-a-matrix). – Nemesis Nov 09 '14 at 14:19

1 Answers1

0

Since Adiel did not post an answer, I'll make their comment a CW: the command

V = find(all(A,2))

does the job, because all(A,2) processes every row, returning 1 if there are any nonzero entries. Then find returns the indices of nonzero entries, which are the desired row numbers.

Similarly, V = find(all(A,1)) works column-wise.