Professional Documents
Culture Documents
clear
x=randn(2,100)-5;
y=randn(2,150);
z=randn(2,200)+5;
T=[x,y,z];
S=size(T);
Length_T=S(2);
plot(T(1,:),T(2,:),'bo');
hold on;
pause(1);
for k=1:30
Gc1=[zeros(2,Length_T)];
Gc2=[zeros(2,Length_T)];
Gc3=[zeros(2,Length_T)];
plot(Z1(1,1),Z1(2,1),'rs','linewidth',3);
plot(Z2(1,1),Z2(2,1),'gs','linewidth',3);
plot(Z3(1,1),Z3(2,1),'bs','linewidth',3);
hold off;
D=find(C==min(C));
if D==1
Gc1(:,j)=T(:,j);
elseif D==2
Gc2(:,j)=T(:,j);
elseif D==3
Gc3(:,j)=T(:,j);
end
end
pause(1);
plot(Gc1(1,:),Gc1(2,:),'ro');
hold on;
plot(Gc2(1,:),Gc2(2,:),'go');
hold on;
plot(Gc3(1,:),Gc3(2,:),'bo');
L1=nnz(Gc1)/2;
L2=nnz(Gc2)/2;
L3=nnz(Gc3)/2;