フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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 回表示 (過去 30 日間)
Parveen verma
Parveen verma 2015 年 6 月 14 日
閉鎖済み: Stephen23 2015 年 6 月 15 日
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

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by