MATLAB: Classification in Parfor Loops

classificationclassifiedparforvariable

parfor xIndex=1:2:c
for yIndex=1:2:c
x = xvec(xIndex);
y = yvec(yIndex);
M(xIndex, yIndex) = EscapeVelocity(-0.123+0.745*1i, x+y*1i, m);
end
end
MatLab says "The variable M in a parfor cannot be classified"
I would appreciate any explanation of why this occurs and how to correct it.

Best Answer

Try constructing
xvec2 = xvec(1:2:c);
nxvec2 = length(xvec2);
yvec2 = yvec(1:2:c);
nyvec2 = length(yvec2);
M2 = zeros(nxvec2, nyvec2);
Then
parfor for xindex = 1 : nxvec2
x = xvec2(xindex);
for yindex = 1 : nyvec2
y = yvec2(yindex);
M2(xIndex, yIndex) = EscapeVelocity(-0.123+0.745*1i, x+y*1i, m);
end
end
Then
M(1:2:c, 1:2:c) = M2;