【发布时间】:2016-09-12 22:01:02
【问题描述】:
我正在尝试在MATLAB 中使以下循环并行友好,以便我可以使用parfor:
for ivert = 1 : nVerts
b = obj.f( obj.neighIDs{ ivert } );
x = obj.coeffMatrix{ ivert } \ b;
obj.solution( ivert, : ) = x( 1 : 3 );
end
我尝试根据here 发布的 MATLAB 文档对变量进行切片:
parfor ivert = 1 : nVerts
i = obj.neighIDs{ ivert };
b = obj.f( i );
A = obj.coeffMatrix{ ivert }
x = A \ b;
obj.solution( ivert, : ) = x( 1 : 3 );
end
但 MATLAB 抱怨说:
Valid indices for `obj` are restricted in PARFOR loops.
有人可以给我一些提示如何在上述循环中分割变量吗?
【问题讨论】:
-
obj.f( i )的索引可能是问题所在。我猜 Matlab 不高兴,你在循环中计算索引。
标签: matlab for-loop parallel-processing parfor