%Create 2 clusters with raddi=1 & centers 2 raddi apart
npts=50;mf=3;
X = [randn(npts,2)+mf*ones(npts,2); randn(npts,2)-mf*ones(npts,2)];
        opts = statset('Display','final');
%Compute labels cidx(i) for points and cluster centers ctrs for the clusters

        [cidx, ctrs] = kmeans(X, 2, 'Distance','city', ...
                              'Replicates',5, 'Options',opts);
        subplot(221);
        plot(X(cidx==1,1),X(cidx==1,2),'r.', ...
             X(cidx==2,1),X(cidx==2,2),'b.', ctrs(:,1),ctrs(:,2),'kx');
        title(['Clusters with Radii=1 & Centers Separated by ',num2str(mf*2),' Raddi'])
        xlabel('x(i)');ylabel('y(i)');
               text(-4,3,[num2str(npts),' points/cluster'])

        subplot(222);
       s = silhouette(X, cidx, 'sqeuclid');
       bar(s)
       title('Silohuette s(i) vs Point Index i')
       xlabel('Point Index i');ylabel('Silohuette s(i)')

% Now Create 2 clusters with raddi=1 & centers 6 raddi apart
       mf=1
      X = [randn(npts,2)+mf*ones(npts,2); randn(npts,2)-mf*ones(npts,2)];
        opts = statset('Display','final');
        [cidx, ctrs] = kmeans(X, 2, 'Distance','city', ...
                              'Replicates',5, 'Options',opts);
        subplot(223);
        plot(X(cidx==1,1),X(cidx==1,2),'r.', ...
             X(cidx==2,1),X(cidx==2,2),'b.', ctrs(:,1),ctrs(:,2),'kx');
title(['Clusters with Radii=1 & Centers Separated by ',num2str(mf*2),' Raddi'])
        xlabel('x(i)');ylabel('y(i)');
                       text(-2.8,3,[num2str(npts),' points/cluster'])
        subplot(224);
       s = silhouette(X, cidx, 'sqeuclid');
       bar(s)
              title('Silohuette s(i) vs Point Index i')
       xlabel('Point Index i');ylabel('Silohuette s(i)')