How can i preallocate memory for sliced output variables in parfor loop?
7 次查看(过去 30 天)
显示 更早的评论
How can i preallocate memory for sliced output variables in a parfor loop? Following is the example mentioned in Matlab Parallel Computing toolbox. The array "b" in the example is the sliced output variable. But, there is no preallocation of memory for "b". Isn't that going to affect the performance of Matlab in parfor loop?
a = 0;
z = 0;
r = rand(1,10);
parfor ii = 1:10
a = ii;
z = z + ii;
b(ii) = r(ii);
end
Thanks.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!