Im trying to use parfor-Loop to speed up the computation. Here is the code (a kind of customized pdist function):
for i = 1:size1-1 for j = i+1:size1 index = index + 1; Y(index) = distance(dataSet(:,:,i),dataSet(:,:,j)); endend
I'm using parfor for the outer loop, but I got an error message on parfor:
- "The PARFOR cannot run due the way variable index is used"
- "The PARFOR cannot run due the way variable Y is used"
and, in the inner loop:
- "Valid indices for Y are restricted in PARFOR loops"
Both the errors occurred because of the use of the indexes in the inner loop, I can't figure out how to change the code for avoiding this problem. I've read the documentation, but i can't figured out how to convert into a parfor loop. How should I use parfor in this context?
Best Answer