randn('state',0)
xr1=0.5*randn(100,1)+4;
xi1=0.5*randn(100,1)+3;
xr2=0.5*randn(100,1)+8;
xi2=0.5*randn(100,1)+5;
% xr1=0.5*randn(100,1)+6;
% xi1=0.5*randn(100,1)+3;
% xr2=0.5*randn(100,1)+7;
% xi2=0.5*randn(100,1)+4;
xx=[xr1 xi1;xr2 xi2];
c1=mean([xr1 xi1]); % centroide clase 1
c2=mean([xr2 xi2]); % centroide clase 2
indices=mezclar([1:200]');
x=xx(indices,:);
plot(x(:,1),x(:,2),'+')
indx=kmeans(x,2);
x1=[];
x2=[];
for k=1:200
    if indx(k)==1
    xx1=x(k,:);
    x1=[x1;xx1];
    else
        xx2=x(k,:);
        x2=[x2;xx2];
    end
end
figure
plot(x1(:,1),x1(:,2),'b+',x2(:,1),x2(:,2),'r+',xr1,xi1,'bo',xr2,xi2,'ro',c1(1),c1(2),'ko',c2(1),c2(2),'ko')