Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Walter Roberson
Walter Roberson le 12 Juin 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 commentaire
Isha Pant
Isha Pant le 13 Fév 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Asad Ullah
Asad Ullah le 23 Avr 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

Catégories

En savoir plus sur WSNs dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by