clc,clear all;
point=[1.40000000000000,0.200000000000000;1.40000000000000,0.200000000000000;1.30000000000000,0.200000000000000;1.50000000000000,0.200000000000000;1.40000000000000,0.200000000000000;1.70000000000000,0.400000000000000;1.40000000000000,0.300000000000000;1.50000000000000,0.200000000000000;1.40000000000000,0.200000000000000;1.50000000000000,0.100000000000000;1.50000000000000,0.200000000000000;1.60000000000000,0.200000000000000;1.40000000000000,0.100000000000000;1.10000000000000,0.100000000000000;1.20000000000000,0.200000000000000;1.50000000000000,0.400000000000000;1.30000000000000,0.400000000000000;1.40000000000000,0.300000000000000;1.70000000000000,0.300000000000000;1.50000000000000,0.300000000000000;1.70000000000000,0.200000000000000;1.50000000000000,0.400000000000000;1,0.200000000000000;1.70000000000000,0.500000000000000;1.90000000000000,0.200000000000000;1.60000000000000,0.200000000000000;1.60000000000000,0.400000000000000;1.50000000000000,0.200000000000000;1.40000000000000,0.200000000000000;1.60000000000000,0.200000000000000;1.60000000000000,0.200000000000000;1.50000000000000,0.400000000000000;1.50000000000000,0.100000000000000;1.40000000000000,0.200000000000000;1.50000000000000,0.200000000000000;1.20000000000000,0.200000000000000;1.30000000000000,0.200000000000000;1.40000000000000,0.100000000000000;1.30000000000000,0.200000000000000;1.50000000000000,0.200000000000000;1.30000000000000,0.300000000000000;1.30000000000000,0.300000000000000;1.30000000000000,0.200000000000000;1.60000000000000,0.600000000000000;1.90000000000000,0.400000000000000;1.40000000000000,0.300000000000000;1.60000000000000,0.200000000000000;1.40000000000000,0.200000000000000;1.50000000000000,0.200000000000000;1.40000000000000,0.200000000000000;4.70000000000000,1.40000000000000;4.50000000000000,1.50000000000000;4.90000000000000,1.50000000000000;4,1.30000000000000;4.60000000000000,1.50000000000000;4.50000000000000,1.30000000000000;4.70000000000000,1.60000000000000;3.30000000000000,1;4.60000000000000,1.30000000000000;3.90000000000000,1.40000000000000;3.50000000000000,1;4.20000000000000,1.50000000000000;4,1;4.70000000000000,1.40000000000000;3.60000000000000,1.30000000000000;4.40000000000000,1.40000000000000;4.50000000000000,1.50000000000000;4.10000000000000,1;4.50000000000000,1.50000000000000;3.90000000000000,1.10000000000000;4.80000000000000,1.80000000000000;4,1.30000000000000;4.90000000000000,1.50000000000000;4.70000000000000,1.20000000000000;4.30000000000000,1.30000000000000;4.40000000000000,1.40000000000000;4.80000000000000,1.40000000000000;5,1.70000000000000;4.50000000000000,1.50000000000000;3.50000000000000,1;3.80000000000000,1.10000000000000;3.70000000000000,1;3.90000000000000,1.20000000000000;5.10000000000000,1.60000000000000;4.50000000000000,1.50000000000000;4.50000000000000,1.60000000000000;4.70000000000000,1.50000000000000;4.40000000000000,1.30000000000000;4.10000000000000,1.30000000000000;4,1.30000000000000;4.40000000000000,1.20000000000000;4.60000000000000,1.40000000000000;4,1.20000000000000;3.30000000000000,1;4.20000000000000,1.30000000000000;4.20000000000000,1.20000000000000;4.20000000000000,1.30000000000000;4.30000000000000,1.30000000000000;3,1.10000000000000;4.10000000000000,1.30000000000000;6,2.50000000000000;5.10000000000000,1.90000000000000;5.90000000000000,2.10000000000000;5.60000000000000,1.80000000000000;5.80000000000000,2.20000000000000;6.60000000000000,2.10000000000000;4.50000000000000,1.70000000000000;6.30000000000000,1.80000000000000;5.80000000000000,1.80000000000000;6.10000000000000,2.50000000000000;5.10000000000000,2;5.30000000000000,1.90000000000000;5.50000000000000,2.10000000000000;5,2;5.10000000000000,2.40000000000000;5.30000000000000,2.30000000000000;5.50000000000000,1.80000000000000;6.70000000000000,2.20000000000000;6.90000000000000,2.30000000000000;5,1.50000000000000;5.70000000000000,2.30000000000000;4.90000000000000,2;6.70000000000000,2;4.90000000000000,1.80000000000000;5.70000000000000,2.10000000000000;6,1.80000000000000;4.80000000000000,1.80000000000000;4.90000000000000,1.80000000000000;5.60000000000000,2.10000000000000;5.80000000000000,1.60000000000000;6.10000000000000,1.90000000000000;6.40000000000000,2;5.60000000000000,2.20000000000000;5.10000000000000,1.50000000000000;5.60000000000000,1.40000000000000;6.10000000000000,2.30000000000000;5.60000000000000,2.40000000000000;5.50000000000000,1.80000000000000;4.80000000000000,1.80000000000000;5.40000000000000,2.10000000000000;5.60000000000000,2.40000000000000;5.10000000000000,2.30000000000000;5.10000000000000,1.90000000000000;5.90000000000000,2.30000000000000;5.70000000000000,2.50000000000000;5.20000000000000,2.30000000000000;5,1.90000000000000;5.20000000000000,2;5.40000000000000,2.30000000000000;5.10000000000000,1.80000000000000];
figure;
plot(point(:,1),point(:,2),'ks','MarkerSize',5);
title 'Fisher''s Iris Data';
xlabel 'Petal Lengths (cm)';
ylabel 'Petal Widths (cm)';
rng(1); % For reproducibility
[idx,C] = kmeans(point,3);
x1 = min(point(:,1)):0.01:max(point(:,1));
x2 = min(point(:,2)):0.01:max(point(:,2));
[x1G,x2G] = meshgrid(x1,x2);
XGrid = [x1G(:),x2G(:)]; % Defines a fine grid on the plot
idx2Region = kmeans(XGrid,3,'MaxIter',1,'Start',C);
figure;
gscatter(XGrid(:,1),XGrid(:,2),idx2Region,[0,0.75,0.75;0.75,0,0.75;0.75,0.75,0],'..');
hold on;
plot(point(:,1),point(:,2),'ks','MarkerSize',5);
title 'Fisher''s Iris Data';
xlabel 'Petal Lengths (cm)';
ylabel 'Petal Widths (cm)';
legend('Region 1','Region 2','Region 3','Data','Location','SouthEast');
hold off;