How to fastly construct a sparse matrix with each column equal to some sparse vector
古いコメントを表示
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 件のコメント
Fabio Freschi
2019 年 9 月 26 日
編集済み: Fabio Freschi
2019 年 9 月 26 日
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
2019 年 9 月 26 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Sparse Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!