You are on page 1of 1

cluster = [1 1 0 0; 0 0 0 1;1 0 0 0; 0 0 1 1]

w = [0.2 0.8; 0.6 0.4; 0.5 0.7; 0.9 0.3]


a(1) = 0.6

for t = 1:2
for l=1:4
for i=1:2
D(i) = (w(1,i)-cluster(l,1))^2+(w(2,i)-cluster(l,2))^2 + (w(3,i)-cluster(l,3))^2 +
(w(4,i)-cluster(l,4))^2;
end
for i=1:4

if D(1)<D(2)
j=1;
k=2;
else
j=2;
k=1;
end
w(i,j) = w(i,j)+a(t)*(cluster(l,i)-w(i,j));
w(i,k) = w(i,k);
end
end
Result = w
a(t+1) = 0.5*a(t);
end

You might also like