I am trying to find all non-zeros elements in a large sparse matrix K(19683000x19683000). I used find to first return the linear indices.
val = K(K~=0);
inds = find(K~=0);
[j, i] = ind2sub(size(K), inds);
% [j, i] = find(K~=0);
i = full(i);
j = full(j);
This gave some error:
Error using find
Matrix is too large to return linear indices.
Use [i,j] = find(S) for sparse matrix.
Error in (line 82)
inds = find(K~=0);
Error in run (line 64)
evalin('caller', [script ';']);
Any idea what is happening and how I can avoid it?