Explanation

The code uses the indicated variable as a reduction variable in the loop, but does not initialize it before the loop. If the variable is not initialized, the result might be undefined. The parfor function supports reductions, which are a kind of parallel construct. Reductions compute a value with contributions from all the iterations (for example, the sum of a vector), but the iterations can still run in an arbitrary order.


Suggested Action

Initialize the reduction variable before the parfor loop starts. For more information, see Reduction Variables.