# How to find the nearest neighbors points in this case ?

14 views (last 30 days)
Arul prasath on 6 Dec 2014
Answered: Rohini Sharma on 30 Apr 2015
just see this image 1 in this they where creating wsn(wireless sensor network). This i have done in matlab you can see my coding also i attached below.
Image-1
Image-2
in this image they are finding nearest sensor node gateway's, so now i want to find the sensor node nearest sensor node gateway's please help me..
Arul prasath on 7 Dec 2014
sir, in this figure 'X' is denoted as gateway node and 'o' this denoted as normal sensor node's.

Image Analyst on 7 Dec 2014
So you don't have to start with an image. You have a list of (x,y) coordinates for gateways and sensors. So why can't you just run through the list with a for loop calculating the distance of each gateway to all the sensors, and select sensors that are closer than some specified distance? Just use the Pythagorean theorem and a double for loop. Draw lines to "close" pairs. Seems pretty easy.
Arul prasath on 7 Dec 2014
ya sir i got it. Thank's a lot....

Rohini Sharma on 30 Apr 2015
Hello Arul and Image Analyst
How to modify the code in order to connect gateway node with only one sensor node? Here gateway node is connection to all sensor node with in its range=10.