Is there a faster way of updating elements in a big matrix?

1 visualizzazione (ultimi 30 giorni)
Is there a faster way of updating elements in a big matrix?
Currently, I have A with a size of 9000000*8760. Each loop I need to update some elements, like: B=randi(800000,10000,1); A(B,:)=5;
Is there a faster way of dealing with big data?
Thank you.
  1 Commento
dpb
dpb il 5 Lug 2018
Until run profiler to know where are slow spots specifically any micro optimization is premature.
W/o other information on code structure nothing to be said;
A(B,:)=5;
is about as efficient as it gets presuming elements of B are already in A which is a class double array...the hint may be in the earlier phrase of "Each loop...". Perhaps that loop or significant portions could be vectorized or otherwise are the bottleneck but crystal ball is in shop for repair (yet again)...

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by