• 大小: 219KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: Matlab
  • 标签:

资源简介

无线传感器网络APIT定位算法的matlab源代码

资源截图

代码片段和文件信息

function APIT(grid_length)
% In APIT the sensor nodes are not homogeneous
% the communication range of anchors is larger than that of unknown nodes
% comm_r: the communication range of the unknown node. it‘s saved in neighbor.mat
% the communication range of the anchor node is : times * comm_r saved in neighbor.mat
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    load ‘../Deploy Nodes/coordinates.mat‘;
    load ‘../Topology Of WSN/neighbor.mat‘;
    %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    disp(‘时间较长,耐心等待...‘);
    unknown_node_index=all_nodes.anchors_n+1:all_nodes.nodes_n;
    row_n=ceil(all_nodes.square_L/grid_length);    col_n=row_n;
    centroid_x=repmat(([1:col_n]-0.5)*grid_lengthrow_n1);
    centroid_y=repmat(transpose(([1:row_n]-0.5)*grid_length)1col_n);
    for i=unknown_node_index   
        disp([num2str(i)‘:我在跑,不要催啦...‘]);
        neighboring_anchor_index=find(neighbor_matrix(i1:all_nodes.anchors_n)==1);
        neighboring_anchor_n=length(neighboring_anchor_index);
        if neighboring_anchor_n>=3
            gridmap=zeros(row_ncol_n);
            grid_covered_flag=zeros(row_ncol_n);
            for a=1:neighboring_anchor_n-2
                for b=a+1:neighboring_anchor_n-1
                    for c=b+1:neighboring_anchor_n
                        %~~判断未知节点i是否在三角形abc内部
                        % Approximate P.I.T Test: “If no neighbor of M is further from/close to all three anchors A B and C simultaneously
                        % M assumes that it is inside triangle abc. OtherwiseM assumes it resides outside the triangle.“
                        neighboring_node_index=setdiff(find(neighbor_matrix(i:)==1)neighboring_anchor_index([a b c]));
                        neighboring_node_rss_of_abc=neighbor_rss(neighboring_node_indexneighboring_anchor_index([a b c]));
                        in_out_judge=neighboring_node_rss_of_abc>repmat(neighbor_rss(ineighboring_anchor_index([a b c]))length(neighboring_node_index)1);
                        if any(sum(transpose(in_out_judge))==0|sum(transpose(in_out_judge))==3)%outside                        
                            Grid_in_triangle_abc=inpolygon(centroid_xcentroid_yall_nodes.estimated(neighboring_anchor_index([a b c])1)all_nodes.estimated(neighboring_anchor_index([a b c])2));%被三角形abc覆盖到的网格
                            gridmap=gridmap-Grid_in_triangle_abc;                              
                        else%inside
                            Grid_in_triangle_abc=inpolygon(centroid_xcentroid_yall_nodes.estimated(neighboring_anchor_index([a b c])1)all_nodes.estimated(neighboring_anchor_index([a b c])2));%被三角形abc覆盖到的网格
                            gridmap=gridmap+Grid_in_triangle_abc;                            
                        end
                        grid_covered_flag=grid_covered_flag|Grid_in_triangle_abc;
                    end
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3714  2010-06-04 11:28  APIT\APIT.m

     文件       3434  2010-06-04 11:28  APIT\PPIT.m

     文件     287486  2008-12-04 16:48  APIT\Range-Free Localization Schemes for Large Scale.pdf

     目录          0  2011-04-20 15:52  APIT

----------- ---------  ---------- -----  ----

               294634                    4


评论

共有 条评论

相关资源