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; 1-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)) 2- what i do :so i selection a node that dist(u,v)<R/2 and max degree(nombre of neighbor) and whos dist(sink,u) is minimale but he does not work : this is my code:
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 end
Best Answer