MATLAB: How to transform a simple for into a parfor

parallel computingParallel Computing Toolboxparfor

Hi, I'm just trying to change this
for i = 1:N
j = i:N;
D(i,j) = euclideandistance(X(i,1),X(i,2),X(j,1),X(j,2));
end
to a parfor loop, but I can't figure out how to do it

Best Answer

  • for i = 1:N
    j = i:N;
    Dj = D(i,:);
    Dj(j) = euclideandistance(X(i,1),X(i,2),X(j,1),X(j,2));
    D(i,:) = Dj;
    end