Math-Model(二)-无向图最近邻路径搜索

原创
2019/01/22 17:02
阅读数 141
%a=xlsread('../附件一:已结束项目任务数据.xls');
clc
clear
GPS_1=importdata('../GPS_DATA.txt');
GPS_2=importdata('../GPS_DATA2.txt');
%X=min([min(GPS_1(:,1)),min(GPS_2(:,1))]):0.01:max([max(GPS_1(:,1)),max(GPS_2(:,1))]);
%Y=min([min(GPS_1(:,2)),min(GPS_2(:,2))]):0.01:max([max(GPS_1(:,2)),max(GPS_2(:,2))]);
figure(1)
plot(GPS_1(:,2),GPS_1(:,1),'*r')%,GPS_2(:,2),GPS_2(:,1),'*b')
figure(2)
plot(GPS_2(:,2),GPS_2(:,1),'*b')
figure(3)
plot(GPS_1(:,2),GPS_1(:,1),'*r',GPS_2(:,2),GPS_2(:,1),'*b')
%插入人员密度值
%Z=griddata(x,y,z,X,Y,'v4');
%%
for i=1:length(GPS_1)
    counter=1;
    counter_task=1;
    gps_point=[0 0 0 0];
    real_distance_list=[0];
    for j=1:length(GPS_2)
        real_distance=eular_distance(GPS_1(i,2),GPS_1(i,1),GPS_2(j,2),GPS_2(j,1));
        if real_distance<12
            gps_point(counter,1)=GPS_2(j,2);
            gps_point(counter,2)=GPS_2(j,1);
            gps_point(counter,3)=GPS_2(j,3);
            gps_point(counter,4)=GPS_2(j,4);
            counter=counter+1;
        end
        real_distance_list(j,1)=real_distance;
    end
    neighbor_counter(i,1)=counter;
    neighbor_limit_mean(i,1)=mean(gps_point(:,3));
    neighbor_reputation_mean(i,1)=mean(gps_point(:,4));
     for j=1:length(GPS_1)
        real_distance=eular_distance(GPS_1(i,2),GPS_1(i,1),GPS_1(j,2),GPS_1(j,1));
        if real_distance<12
            counter_task=counter_task+1;
        end
     end
    neighbor_task_counter(i,1)=counter_task;
    min_distance(i,1)=min(real_distance_list);
end
tabel=[neighbor_counter,neighbor_limit_mean,neighbor_reputation_mean,min_distance,neighbor_task_counter]
%%
plot([1:length(GPS_1)],neighbor_counter,'b')
%%
function real_distance=eular_distance(longitude1,Latitude1,longitude2,Latitude2)
real_distance=distance([Latitude1,longitude1],[Latitude2,longitude2])/180*pi*6371.393;
end

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部