Uninitialized Temporaries Temporary variables in a parfor-loop are cleared at the beginning of every iteration. MATLAB can sometimes detect cases in which loop iterations use a temporary variable before it is set in that iteration.
Examples include conditionally setting a variable before any use of the variable.
function myFunction
parfor i = 1:10
if rand < 0.5
a = MyClass;
end
disp(a.SomeValue);
end
end
Likewise, not setting a variable on all possible code paths.
function myFunction
parfor i = 1:10
if rand < 0.5
a = MyClass;
else
end
disp(a.SomeValue);
end
end
Best Answer