clear all;clc;tic;
X=[
91.8244186,22.3705287;
92.0069949,21.4282895;
90.3917291,23.764319;
90.3858206,22.4929908;
91.8780611,24.9015238;
88.6074625,24.3750433;
89.2166017,23.1468977;
];
k=2;
[Idx,Ctrs,SumD,D]=kmeans(X,k);
plot(X(Idx==1,1),X(Idx==1,2),'r.','MarkerSize',14)
hold on
plot(X(Idx==2,1),X(Idx==2,2),'b.','MarkerSize',14)
plot(Ctrs(:,1),Ctrs(:,2),'kx','MarkerSize',14,'LineWidth',4)
plot(Ctrs(:,1),Ctrs(:,2),'kx','MarkerSize',14,'LineWidth',4)
legend('The first type of city','The second type of city','Eco Zone','Location','NW')
toc;
这里以建立生态区为例,为了使所建生态区能够辐射到更多的城市,使用K-means聚类算法确定要建立的生态区的经纬度