-
大小: 219KB文件類型: .rar金幣: 2下載: 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
評論
共有 條評論