資源簡介
鑒于學(xué)習(xí)WSN定位的同行越來越多,先將自己編寫,并得到驗(yàn)證的RSSI算法的MATLAB代碼分享給大家,希望有所幫助。
代碼片段和文件信息
function?RSSI()
%?未知節(jié)點(diǎn)利用鄰居錨節(jié)點(diǎn)進(jìn)行定位,沒有鄰居錨節(jié)點(diǎn)的未知節(jié)點(diǎn)無法定位
%?根據(jù)接收信號(hào)強(qiáng)度轉(zhuǎn)化為距離。規(guī)則傳播模型下得到的距離跟實(shí)際距離沒有誤差
%?不規(guī)則通信模型下,規(guī)則傳播模型下得到的距離跟實(shí)際距離存在誤差
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
????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é)點(diǎn)進(jìn)行定位
????????neighboring_anchor_n=length(neighboring_anchor_index);
????????if?neighboring_anchor_n>=3
????????????try
????????????????dist=rss2dist(neighbor_rss(neighboring_anchor_indexi)1);
評(píng)論
共有 條評(píng)論