How can you delete a random fraction of entries from a sparse matrix?
Show older comments
a - sparse matrix f - fraction which should be removed
I tried:
nonZeros = nnz(A);
[i,j,s] = find(A);
s = RandStream('mt19937ar','Seed',0);
selection = randperm(s,floor((1-f/100) * nonZeros));
i = i(selection);
j = j(selection);
s = s(selection);
A = sparse(i,j,s);
On line "i = i(selection);" I get the error message: "You cannot index into a RandStream using () indexing."
Accepted Answer
More Answers (0)
Categories
Find more on Sparse Matrices 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!