%% 读入全国省市经纬度坐标
clear;
% 初始化参数
coordinate_file = 'lat_lng.xlsx'; % 经纬度坐标
[num,txt] = xlsread(coordinate_file);
%% 基本信息获取
Lat=num(1:end,1);
Lng=num(1:end,2);
Max_lat=max(Lat);
Min_lat=min(Lat);
Max_lng=max(Lng);
Min_lng=min(Lng);
figure(1);
plot(Lng,Lat,'b.','markersize',6);
%% 聚类分析
[type,center]=kmeans(num,7);
rows=size(center,1);
for i=1:rows
fprintf('聚类号为%1.f的聚类中心坐标为:%f,%f\n',i,center(i,1),center(i,2));
end
h=figure(2);
hold on;
plot(Lng(type==1),Lat(type==1),'ro','markersize',6);
plot(Lng(type==2),Lat(type==2),'bx','markersize',6);
plot(Lng(type==3),Lat(type==3),'g*','markersize',6);
plot(Lng(type==4),Lat(type==4),'m.','markersize',6);
plot(Lng(type==5),Lat(type==5),'c+','markersize',6);
plot(Lng(type==6),Lat(type==6),'m.','markersize',6);
plot(Lng(type==7),Lat(type==7),'c+','markersize',6);
plot(center(:,2),center(:,1),'ro','markersize',12) ;
hold off;
————————————————
版权声明:本文为CSDN博主「LLG_llg_llg」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/LLG_llg_llg/article/details/53192840
图片.png