function D = Distancia_JMS(V)
% Find the matrix of distance between a set of n points
% Input:
%   V(nd,n) : coordinates of n points in nd dimensions
% Ouput:
%   D(n,n)  : matrix of distances between the n points

n = size(V,2);
for i = 1:n
  for j = 1:n
    D(i,j) = norm(V(:,i)-V(:,j));
  end
end

% An alternative way, using that (Vi-Vj)^2=Vi^2+Vj^2-2*Vi*Vj
% V2 = sum(V.^2);
% D = sqrt(V2+V2'-2*V'*V);

end
