Anyone can tell me how I efficiently delete some rows in sparse
matrix?
I found manipulation for full matrix and sparse is very different.
for example--deleting rows in matrix.
a=eye(1000,1000);
b=[2,3,5]';
a(b,:)=[]; %speed is fast.
c=speye(1000,1000);
b=[2,3,5]';
c(b,:)=[]; %speed is very low.
This is only for example. How can I get fast speed for sparse matrix?
thanks a lot.
Indeed, even deleting the early columns is slow because all the following columns need to be shifted along in the data structure.
You might be better off
(1) transposing your matrix first, if you are going to be doing alot of row deletions. The column deletions may be faster.
(2) using find and then working with the i,j, and s vectors returned instead.
(3) Just use full. sparse is useful for much larger matrices (with mostly nonzeros).
Penny Anderson
The MathWorks, Inc.
"lifei zhang" <shifei...@yahoo.com> wrote in message news:eea9d...@WebX.raydaftYaTP...