MATLAB: How do we calculate Euclidean Distance Matrix in Matlab

Statistics and Machine Learning Toolbox

Dear matlab Experiences
I have (A) matrix where rows instances and columns features, such as A=[1,0,0.21,…etc];
I would like to calculate Distance matrix for A, when i browsed matlab functions and question i have found so many answers but i don't know which one satisfy Euclidean distance matrix ?
both codes give a distance matrix, can please some one give an explanation about second code? and is matlab support another distance matrix like : squared Euclidean distance, dot product, edit distance, manhaten?
functions are:
Distancematrix = dist(A);
and
distmatrix = squeeze(sqrt(sum(bsxfun(@minus,A,reshape(A',1,size(A,2),size(A,1))).^2,2)))
thanks

Best Answer

Related Question