How to fastly construct a sparse matrix with each column equal to some sparse vector
Mostrar comentarios más antiguos
Dear community,
I have 2000 sparse arrays H(i), i=1,...2000, with each of size 100000*5, now I'd like to construct a new sparse matrix X of size 100000*2000 with its i-th column equal to the first column of H(i). The simple way is just a loop:
X = sparse(100000,2000);
for i=1:2000
X(:,i) = H(:,1);
end
However, Such an assignment is slow. Is there any better way? Thanks !
Bo
2 comentarios
Fabio Freschi
el 26 de Sept. de 2019
Editada: Fabio Freschi
el 26 de Sept. de 2019
Not clear: is H an array (you use H(i)) or a matrix (in the loop: H(:,1)). or maybe a cell array where each H{i} is a 100000*5 matrix?
Can you share the data to play with?
yu wen
el 26 de Sept. de 2019
Respuestas (0)
Categorías
Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!