How is parfor time taken is larger than that by normal for loop ?

回答 (1 件)

Sindar
Sindar 2020 年 7 月 17 日

0 投票

Best guess: you don't preallocate y, nor clear it. So, the parfor needs to expand the vector constantly while the for is simply overwriting elements. Try
x=1:4000;
y1=false(size(x));
y2=false(size(x));
...
y1(i)=
...
y2(i)=

カテゴリ

ヘルプ センター および File ExchangeParallel for-Loops (parfor) についてさらに検索

質問済み:

2020 年 7 月 17 日

回答済み:

2020 年 7 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by