how can i calculate the nombre of neighbors of wsn

2 Ansichten (letzte 30 Tage)
ali hadjer
ali hadjer am 8 Nov. 2015
Kommentiert: Walter Roberson am 8 Nov. 2015
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

Antworten (0)

Kategorien

Mehr zu WSNs finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by