Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

I have used the following code to create a wsn virtual structure with 4*4 grid-cells and have deployed 100 nodes in it. Each cell is headed by a cluster-head which is in center of the cell i.e their are a total of 16 cluster-heads.Now the whole wsn a

1 vue (au cours des 30 derniers jours)
Parveen verma
Parveen verma le 14 Juin 2015
Clôturé : Stephen23 le 15 Juin 2015
I have used the following code to create a wsn virtual structure with 4*4 grid-cells and have deployed 100 nodes in it. Each cell is headed by a cluster-head which is in center of the cell i.e their are a total of 16 cluster-heads.Now the whole wsn area is also headed by a single "Area-header" which is in the center of the whole wsn area. Now,how will the cluster-heads collect the information from the nodes of their respective cells? 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
%All good upto here
%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

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by