I am trying to make the following loop parallel-friendly in MATLAB so that I can use parfor:
for ivert = 1 : nVerts
b = obj.f( obj.neighIDs{ ivert } );
x = obj.coeffMatrix{ ivert } \ b;
obj.solution( ivert, : ) = x( 1 : 3 );
end
I tried to slice the variables according to MATLAB documentation posted here:
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
But MATLAB complains that:
Valid indices for `obj` are restricted in PARFOR loops.
Could someone give me some hints how to slice the variables in the above loop?
obj.f( i )might be the problem. I guess Matlab is unhappy, that you calculate the index within the loop. - Alexander Büse