フィルターのクリア

I want to introduce a "mobile-sink" outside the boundary of the wsn structure.I have used the following code to create a wsn structure with 4*4 cell grids and have deployed randomly 100 nodes in it. Now, how could a "mobile-sink" be introduced outsid

1 回表示 (過去 30 日間)
I want to introduce a "mobile-sink" outside the boundary of the wsn structure.I have used the following code to create a wsn structure with 4*4 cell grids and have deployed randomly 100 nodes in it. Now, how could a "mobile-sink" be introduced outside the boundary of the 4*4 cell grid wsn structure.Please help.
NrGrid = 4; % Number Of Grids
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
NrGrid = 4;
coords = rand(100,2) * maNrGrid + 1;
scatter(coords(:,1),coords(:,2));
set(gca, 'XTick', 1:maNrGrid+1, 'YTick', 1:maNrGrid+1)
grid on

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 12 日
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
Afterwards sink_coords will be a randomly located position somewhere outside or on the boundary of the grid. If you do not want the boundary to be included, use < and > instead of <= and >=
Note: the randomly selected location could end up several galaxies over from the grid, since the only requirement was that it be outside.
  1 件のコメント
Isha Pant
Isha Pant 2019 年 2 月 13 日
This is not running.
I have deployed 100 random sensors in rectangular sensor field. Now the task is "Introduction of the mobile sink" in the boundaries of the sensor field.How to code it ?
I need a general implementation code for implementing a mobile sink. Please help.

サインインしてコメントする。

その他の回答 (1 件)

Asad Ullah
Asad Ullah 2022 年 4 月 23 日
i have the same question. i have also deployed 100 nodes randmoly and the sink is placed in a specific position but i want mobility across x-axis

カテゴリ

Help Center および File ExchangeWSNs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by