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

2 ビュー (過去 30 日間)
Chaoyang Jiang
Chaoyang Jiang 2018 年 7 月 5 日
コメント済み: dpb 2018 年 7 月 5 日
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 件のコメント
dpb
dpb 2018 年 7 月 5 日
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)...

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by