Demo entry 6741520

t1

   

Submitted by anonymous on May 15, 2018 at 17:32
Language: Matlab. Code size: 1.8 kB.

% 新街口 32.041786,118.784115
% 禄口机场 31.734058, 118.873936
% 南京南  31.969303, 118.796959
% 南京站 32.086423, 118.797231
% 江宁金鹰 31.931860, 118.821191
% 溧水县政府 31.651272, 119.027975
% 高淳县政府 31.323221, 118.881799
% % % %

convenient=zeros(60,1);
center_j_new=(center_j-ave_la)./max_la;
center_w_new=(center_w-ave_long)./max_long;
price_norm=price./max(price);
for i=1:60
    convenient(i)=(metro(i)^2+((bus(i))^(1/3)))^(0.5);
    ss=zeros(7,1);
    for j=1:7
        ss(j)=(price_norm(j)/((center_j_new(j)-normal_la(i))^2+(center_w_new(j)-narmal_long(i))^2));
    end
    sss=sum(ss);
    convenient(i)=convenient(i)*sss;
end
norm_convenient=convenient./max(convenient);
%[a,b,c]=meshgrid(normal_la,narmal_long,norm_convenient);
%mesh(a,b,c);
scatter3(normal_la,narmal_long,norm_convenient);
hold on;
scatter3(center_j_new,center_w_new,[0,0,0,0,0,0,0],500,'.');
% 核心点的交通便利程度为1
distance_real=zeros(60,60);
for i=1:60
    for j=1:60
        distance(i,j)=(((latitude(j)-latitude(i))^2+(longitude(j)-longitude(i))^2))^(0.5);
    end
end

tag=zeros(60,1);  %9类,分类


% intialize
for i=1:1000
    kmeansnodesum_la=zeros(9,1);
    kmeansnodesum_long=zeros(9,1);
    kmeanscount=zeros(9,1);
    tocenterdis=zeros(60,9);
    for j=1:60
        for k=1:9
            tocenterdis(j,k)=(((latitude(j)-Kmeansnode_la(k))^2+(longitude(j)-Kmeansnode_long(k))^2))^(0.5);
        end
    end
    [minium,tag]=min(tocenterdis');
    for j=1:60
        kmeansnodesum_la(tag(j))=kmeansnodesum_la(tag(j))+latitude(j);
        kmeansnodesum_long(tag(j))=kmeansnodesum_long(tag(j))+longitude(j);
        kmeanscount(tag(j))=kmeanscount(tag(j))+1;
    end
    Kmeansnode_la=kmeansnodesum_la./kmeanscount;
    Kmeansnode_long=kmeansnodesum_long./kmeanscount;
end

tag=tag';

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).