Beruflich Dokumente
Kultur Dokumente
D:\!!!!!Course_Fall_2014\ai_lab_super_final\matlab_17_dec_2014\MA...\k_means2.m
1 of 2
while(~isequal(center,oldCenter)) %as long as previous center and the new center is not equal the
loop will continue.
D = zeros(k,numData);
G = zeros(k,numData);
1/6/15 8:40 PM
D:\!!!!!Course_Fall_2014\ai_lab_super_final\matlab_17_dec_2014\MA...\k_means2.m
2 of 2
end
plot(x,y,'*','MarkerSize',10); %to hide the previous plots. (as "hold on" will be executed so this
line of code must be executed otherwise previous plot's initial rectangled centers will be visible in
the final plot(that is not what we want).)
hold on %holding the previous plot (superimposition mode on). Meaning all the next plots will be
superimposed with the previous plot until "hold off" is executed.
for i= 1:k
plot(data(1,group{i}),data(2,group{i}),'*','Color',c(i),'MarkerSize',10); %plotting each group
with diffent color
plot(center(1,i),center(2,i),'ks','LineWidth',2,'MarkerFaceColor',c(i),'MarkerSize',10); %
plotting center of each group with different colored filled rectangle
end
hold off %superimposition mode off
axis([0 6.5 0 5.5]) %x axis's screen size is set: from 0 to 6.5 and Y axis's screen size is set:
from 0 to 5.5
end
function d = find_distance(d,c)
end