How do I convert a for-Loop Into parfor-Loops?
Show older comments
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));
end
end
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?
Accepted Answer
More Answers (0)
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!