Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Help with vectorization of my code
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello all. I have a code like below
cd = [21543;21544;21545;21546;21547;21548;21549];
for i=1:7
K(2*cd(i)-1,2*cd(i)-1)= K(2*cd(i)-1,2*cd(i)-1) + St(1,1,i);
K(2*cd(i)-1,2*cd(i))= K(2*cd(i)-1,2*cd(i)) + St(1,2,i);
end
K is a sparse matrix of size [44044 x 44044] and 'St' is a 3D array. I've tried to vectorize this code with no success. Could anyone please help?
Thanks.
3 Commenti
Walter Roberson
il 4 Lug 2016
... do not allow it to grow in size. Assign it the maximum size before the loop. It will speed up your code a lot.
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!