How is parfor time taken is larger than that by normal for loop ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
The time taken (t1) by parfor is larger than that (t2) by the normal for loop,I don't understand why ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333162/image.png)
0 Kommentare
Antworten (1)
Sindar
am 17 Jul. 2020
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)=
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!