% calculate the distance between any two points.

ncol = 2000; 
a = rand(3,ncol);
b = rand(3,ncol);

tic;

c = zeros(ncol,ncol);

for j =1:ncol
    for i = 1:ncol
        x = a(1,j) - b(1,i);
        y = a(2,j) - b(2,i);
        z = a(3,j) - b(3,i);
        c(i,j) = sqrt( x*x + y*y + z*z );
    end
end

toc;

