calculate distance between points dd = vb_mutual_distance(X) --- Input X : N point coordinate [ N x D ] --- Output dd(n,m) : distance between X(n.:) and X(m,:) Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function dd = vb_mutual_distance(X) 0002 % calculate distance between points 0003 % dd = vb_mutual_distance(X) 0004 % --- Input 0005 % X : N point coordinate [ N x D ] 0006 % --- Output 0007 % dd(n,m) : distance between X(n.:) and X(m,:) 0008 % 0009 % Copyright (C) 2011, ATR All Rights Reserved. 0010 % License : New BSD License(see VBMEG_LICENSE.txt) 0011 0012 [N, D] = size(X); 0013 0014 dd = zeros(N,N); 0015 0016 for n=1:N 0017 dd(:,n) = sqrt( sum( vb_repadd(X , - X(n,:)).^2 , 2) ); 0018 end