% Clustering example using PRTools.

% 500 points per class, variance 1.
n = 500;
variance = 1;
clusters = 2;
A = gendatb(n,variance);

% Note: scatterd is a PRTools call.
scatterd(A);

% Cluster the data using kmeans.
[L,A] = kmeans(A,clusters, 50, 'rand');

S = size(A);
L = A.labels();
D = A.data();

% Create a second figure window to show the cluster results separately.
figure;
hold on;

% Show the points in cluster 1 in black, in cluster 2 as yellow.
for i = 1:S(1)
	nextlabel = L(i);
	% NOTE: 'scatter' is a built-in MATLAB function.
	if nextlabel == 1
		scatter(D(i,1), D(i,2), 'k*');
	else
		scatter(D(i,1), D(i,2), 'y*');
	end
end
