How to find the indices of nonzero rows in a matrix?
Example:
A = [ 14 0 6 9 8 17 85 14 1 3 0 99 0 0 0 0 0 0
You can use
ix = any(x,2);
any check whether there is any element that is not a zero. The second argument stands for "per-row" computation.
any
If you want to get the numeric index, you can use find function:
find
numIx = find(ix);
Another method:
ix = sum(abs(x),2)~=0;