Effacer les filtres
Effacer les filtres

I want to elect an "Area-header" of the 4*4 cell-grid wsn structure , which would be at the center of the whole area. Their would be only one "Area-header" in the whole network which will track the position of the "mobile-sink" . I have used the foll

2 vues (au cours des 30 derniers jours)
I want to elect an "Area-header" of the 4*4 cell-grid wsn structure , which would be at the center of the whole area. Their would be only one "Area-header" in the whole network which will track the position of the "mobile-sink" . I have used the following code to create a wsn structure with 4*4 cell grids and have deployed randomly 100 nodes in it and a "mobile sink" being introduced outside the boundary the wsn structure. Now how this "Area-header" will be introduced to track the position of the "mobile-sink"? Please help.
% WSN Grid structure with 4*4 cells made
NrGrid = 4;
x = linspace(0, 100, NrGrid+1);
[X,Y] = meshgrid(x);
figure(1)
plot(X,Y,'k')
hold on
plot(Y,X,'k')
hold off
set(gca, 'Box','off', 'XTick',[], 'YTick',[])
axis square
% grid formation ends
% Nodes deployment started
NrGrid = 4;
coords = rand(100,2) * NrGrid + 1;
scatter(coords(:,1),coords(:,2));
set(gca, 'XTick', 1:NrGrid+1, 'YTick', 1:NrGrid+1)
grid on
% Nodes deployment ends
%cluster head selection on basis of most near to the center
[XC, YC] = ndgrid(1/2:NrGrid+1/2, 1/2:NrGrid+1/2);
center_idx = zeros(NrGrid, NrGrid);
k=16;
for K = 1 : numel(XC)
xc = XC(K);
yc = YC(K);
dists = sqrt((coords(:,1)-xc).^2 + (coords(:,2)-yc).^2);
[mindist, minidx] = min(dists);
center_idx(k) = minidx;
end
%cluster head selection ends
energy(1:100) = sqrt(7) /2E7; % Energy given to all the nodes around 0.5 joules
%Mobile sink introduced
while true
sink_coords = randn(1,2) * NrGrid + NrGrid/2;
if sink_coords(1) < 1 | sink_coords(1) > NrGrid + 1 | sink_coords(2) < 1 | sink_coords(2) > NrGrid + 1
break
end
end

Réponses (0)

Catégories

En savoir plus sur WSNs dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by