how can i calculate the nombre of neighbors of wsn

3 ビュー (過去 30 日間)
ali hadjer
ali hadjer 2015 年 11 月 8 日
コメント済み: Walter Roberson 2015 年 11 月 8 日
i want to deploy a wsn in 100*100 axes with n node and R radius i calculat a distance between all the node and between a sink(100,100)position; i want to calculte the nombre of neighbor (degree) for each node (i supose that distance(u,v)<R/2 to be neighbor(u,v))i supose that the range of sensor (r)is equal to 2* R(range of communication) so i want to wait until i have calculated the degree for every node and then once that has been completed, find (plot)that node with the maximum degree and minimum distance to the sink.) + the condition of dist<d<(handles.r) and save it in new matrix 2 .my code is :
net = [1:n;rand([1,n])*x;rand([1,n])*y];
net1 = net;
*************%
degree=[];
if isfield(handles,'net')
for i = 1:numel(handles.net(1,:))
degree(i)=0;
for j = 1:numel(handles.net(1,:))
X1 = handles.net(2,i);
Y1 = handles.net(3,i);
X2 = handles.net(2,j);
Y2 = handles.net(3,j);
xSide = abs(X2-X1);
ySide = abs(Y2-Y1);
d = sqrt(xSide^2+ySide^2);% distance euclidienne
DD(:,i)=d;
%disp(DD);
%RESORTIR LES NOEUD REDONDANTS
if (d<(handles.r))&&(i~=j)
degree(i)=degree(i)+1;% CALCULE LEs nombre de neighbord( DEGRE) DES NOEUDS REDONDANTS
disp(degree(i))
if (max(degree))%&&(min(handles.d_sink))
plot([X1,X2],[Y1,Y2],'o','LineWidth',0.1);
grid on;
end
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeWSNs についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by