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 CenterFile Exchange 中查找有关 WSNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by