X = rand(5, 2);
Y = randn(2,2);
i=1;
while i<10
a = sum((X-Y(1,:)).*(X-Y(1,:)),2);
b = sum((X-Y(2,:)).*(X-Y(2,:)),2);
[val,assign] = min([a b],[],2);
cluster1idx = find(assign ==1);
Y(1,:)= mean(X(cluster1idx,:));
cluster2idx = find(assign ==2);
Y(2,:)= mean(X(cluster2idx,:));
a = sum((X(cluster1idx,:)-Y(1,:)).*(X(cluster1idx,:)-Y(1,:)),2);
b = sum((X(cluster2idx,:)-Y(2,:)).*(X(cluster2idx, :)-Y(2,:)),2);
i=i+1;
end
1 Comment
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/550338-how-can-i-track-the-random-numbers-generated-by-rand-2-2#comment_902835
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/550338-how-can-i-track-the-random-numbers-generated-by-rand-2-2#comment_902835
Sign in to comment.