%% Script file for HW 6 with new data close all; %Close all open figures clear; %Clear the memory clc; %Clear the command window %Initialize data: load SixDatasets X=XX{1}; NumPts=299; clear XX; NumClusters=5; for j=1:20 temp=randperm(NumPts); C=X(temp(1:NumClusters),:); for k=1:20 [P,C,Err]=kmeansUpdate(X,C); end plot(X(:,1),X(:,2),'k.'); hold on plot(C(:,1),C(:,2),'r*'); hold off pause(0.1); %Draw now and pause (otherwise, the graphs would go by too quickly) Trial(j)=sum(Err); end figure(2) plot(Trial)