clear; clc; close all;

t = linspace(0, 2 * pi, 360);
x = cos(t) + randn(1, 360);
y = sin(t) + randn(1, 360);

figure;
plot(x, y, '.'); hold on;

data = [x', y'];
[labels, C] = kmeans(data, 3, 'start', 'uniform');
for i = 1 : 3
    mask = labels == i;
    plot(x(mask), y(mask), 'o');
end