Storage of sparse matrices
Afficher commentaires plus anciens
Hi,
I have a problem to create a sparse matrix in a loop. I use the following code :
% init the sparse matrix to zeros with ns=272 and nc = 50
B=sparse(ns*nc,ns*nc);
% in the loop I do
tic
B=B+sparse(ii,jj,M2L,ns*nc,ns*nc);
toc
with ii, jj, M2L a vector of dim=50 x 1
The code takes 0.0002 sec in the beginning, but the time increases gradually (It can take about 0.0383 sec after).
What can I do to reduce this time of storage ?
Best regards
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!