資源簡介
鑒于學習WSN定位的同行越來越多,先將自己編寫,并得到驗證的RSSI算法的MATLAB代碼分享給大家,希望有所幫助。
代碼片段和文件信息
function?RSSI()
%?未知節(jié)點利用鄰居錨節(jié)點進行定位,沒有鄰居錨節(jié)點的未知節(jié)點無法定位
%?根據接收信號強度轉化為距離。規(guī)則傳播模型下得到的距離跟實際距離沒有誤差
%?不規(guī)則通信模型下,規(guī)則傳播模型下得到的距離跟實際距離存在誤差
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
????load?‘../Deploy?Nodes/coordinates.mat‘;%此部分需要自己編寫
????load?‘../Topology?Of?WSN/neighbor.mat‘;????
????directory=cd;
????cd?‘../Topology?Of?WSN/Transmission?Model/‘;????
????cd(model);
????unknown_node_index=all_nodes.anchors_n+1:all_nodes.nodes_n;
????for?i=unknown_node_index
????????neighboring_anchor_index=intersect(find(neighbor_matrix(i:)==1)find(all_nodes.anc_flag==1));%只利用鄰居錨節(jié)點進行定位
????????neighboring_anchor_n=length(neighboring_anchor_index);
????????if?neighboring_anchor_n>=3
????????????try
????????????????dist=rss2dist(neighbor_rss(neighboring_anchor_indexi)1);
評論
共有 條評論