Code covered by the BSD License  

Highlights from
(simple) Tool for estimating the number of clusters

from (simple) Tool for estimating the number of clusters by Kaijun Wang
12 validity indices, illustrate estimation of the number of clusters

similarity_euclid(data)
function [R, dmax]= similarity_euclid(data)
% input:    data --- observations x dimensions
% output: R --- nrow * nrow matrix with all the pairwise Euclidean distances
%             between nrow observations in the dataset.

nrow = size(data,1);
R=zeros(nrow,nrow);
data = data';
dmax=0;

% distance between two observations
for i=1:nrow-1
 x=data(:,i);
 for j=i+1:nrow
   y=x-data(:,j);
   d=y'*y;
   d=sqrt(d);
   R(i,j) = d;
   R(j,i) = d; 
   if d>dmax 
       dmax=d; 
   end
 end
end

Contact us at files@mathworks.com