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 view (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 12 Jun 2015
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 Comment
Isha Pant
Isha Pant on 13 Feb 2019
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.

Sign in to comment.

More Answers (1)

Asad Ullah
Asad Ullah on 23 Apr 2022
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

Categories

Find more on WSNs in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!