How do I vectorize these for loops?
I am looking for the fastest implementation.
Thank you!
My current implementation is
d = zeros(N,N);for i = 1:N for j = i:N d(i,j) = vecnorm( Phi(:,i) - Phi(:,j) ); endendd = d + d';
MATLABvectorization
d = zeros(N,N);for i = 1:N for j = i:N d(i,j) = vecnorm( Phi(:,i) - Phi(:,j) ); endendd = d + d';
Best Answer