【发布时间】:2014-08-27 15:46:10
【问题描述】:
我尽最大努力遵循并行工具箱的文档,但仍然无法避免重复使用嵌套循环中索引的数组的问题。 问题在于变量 node
parfor i=1:nX
for j=1:nY
[ind,dist]=findInCircle(node(i,j,:), part,r);
UV=calcVelocity(part(ind,:), dist,node(i,j,:)) ;
%here matlab complains that node is not indexed properly
node(i,j,3)= UV(1);
node(i,j,4)= UV(2);
node(i,j,5)= UV(3);
end
end
我不使用嵌套循环之外的数组,索引也是按照规则来的。我错过了另一个 parfor 限制吗?
【问题讨论】:
-
您是否预先分配了
node?这可能会导致问题。
标签: matlab parallel-processing parfor