User`s guide

2 Parallel for-Loops (parfor)
2-40
b = false;
end
...
end
This loop is acceptable as an ordinary for-loop, but as a parfor-loop, b is a temporary
variable because it occurs directly as the target of an assignment inside the loop.
Therefore it is cleared at the start of each iteration, so its use in the condition of the if
is guaranteed to be uninitialized. (If you change parfor to for, the value of b assumes
sequential execution of the loop, so that do_something(i) is executed for only the lower
values of i until b is set false.)
Temporary Variables Intended as Reduction Variables
Another common cause of uninitialized temporaries can arise when you have a variable
that you intended to be a reduction variable, but you use it elsewhere in the loop, causing
it technically to be classified as a temporary variable. For example:
s = 0;
parfor i = 1:n
s = s + f(i);
...
if (s > whatever)
...
end
end
If the only occurrences of s were the two in the first statement of the body, it would
be classified as a reduction variable. But in this example, s is not a reduction variable
because it has a use outside of reduction assignments in the line s > whatever.
Because s is the target of an assignment (in the first statement), it is a temporary, so
MATLAB issues an error about this fact, but points out the possible connection with
reduction.
Note that if you change parfor to for, the use of s outside the reduction assignment
relies on the iterations being performed in a particular order. The point here is that in
a parfor-loop, it matters that the loop “does not care” about the value of a reduction
variable as it goes along. It is only after the loop that the reduction value becomes usable.
More About
“Classification of Variables in parfor-Loops” on page 2-23