HOW TO IMPROVE THE ASSIGNMENT OF DATA IN A SPARSE MATRIX?

1 visualizzazione (ultimi 30 giorni)
Hi, All,
I want to improve this code, i have to use sparse matrix and store the data from matrix A to RIG(sparse matrix).
RIG=sparse(10000,10000);
A=rand(3,3);
GDL = randi([10 9000],10000,3);
for i=1:10000
P=GDL(i,:);
RIG(P,P)=A;
end
Total Time:0.930 aprox
Thanks for your time! Any reply will be highly appreciated!
  1 Commento
Walter Roberson
Walter Roberson il 17 Set 2019
Use spalloc to set the matrix to hold 9*10000 elements. That will make the assignment more efficient.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by