Skip to content

Commit 1f10c45

Browse files
author
Merouane Atig
committed
Compute centroids
1 parent 389e25e commit 1f10c45

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mlclass-ex7/computeCentroids.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828

2929

3030

31-
32-
31+
for i=1:K
32+
indices = idx == i;
33+
for j=1:n
34+
centroids(i, j) = sum(X(:, j) .* indices) / sum(indices);
35+
end
36+
end
37+
3338

3439

3540

0 commit comments

Comments
 (0)