필터 지우기
필터 지우기

how I can find the central point in randomly distributed WSN and how I can get the nearest sensor node for this point?

조회 수: 1 (최근 30일)
y_cor = 100
x_cor = 100
n = 10
I need to find the nearest node for the central and defined it as a Cluster Head.
All Thanks;

채택된 답변

Image Analyst
Image Analyst 2021년 9월 11일
To find the x and y closest to the mean/centroid in a set of (x,y) coordinates you can do (untested)
meanx = mean(x);
meany = mean(y);
distances = sqrt((x - meanx) .^ 2 + (y - meany) .^ 2);
% Find the distance that is closest to the means.
[minDistance, indexOfMin] = min(distances);
xClosestToCentroid = x(indexOfMin);
yClosestToCentroid = y(indexOfMin);
  댓글 수: 10
Image Analyst
Image Analyst 2021년 9월 12일
@Momen AlManaseh, since I did this
distances = sqrt((x - meanx) .^ 2 + (y - meany) .^ 2);
distances is the distances of all nodes to the centroid. If you want the distances from all the nodes to the node that is closest to the centroid (and may not be exactly at the centroid), then you can use the location of that node instead of meanx and meany:
distances = sqrt((x - xClosestToCentroid) .^ 2 + (y - yClosestToCentroid ) .^ 2);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 WSNs에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by