%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  DEMO - K-means algoritmus
%         (Euklidovska vzdalenost)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clusternum=5;
sigma=2 ;
xlen=1000; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CC=[-10 -10; 10 3; 0 0 ; 20 -4; -3 7]; 

X=[sigma*randn(xlen,1) sigma*randn(xlen,1) ];

for ii=1:xlen ;
    
    jj=ceil(5*rand(1)) ;
    
    X(ii,:)=X(ii,:)+CC(jj,:);    
    
end

figure(1) ; 
plot(X(:,1),X(:,2),'c.') ;
hold on 
plot(CC(:,1),CC(:,2),'or') ;

[idx,C]=kmeans(X,clusternum);
plot(C(:,1),C(:,2),'xb') ;



hold off

