how to get value .if i know the coordinates value
1 次查看(过去 30 天)
显示 更早的评论
suppose i create a network and all nodes are randomly plot on the graph.I know the coordinates value but how to get the particular node value at XY location. X=X1(1) it contain the X coordinate value Y=X1(2) it contain the Y coordinate value XY={X,Y}
0 个评论
回答(1 个)
Image Analyst
2015-4-11
Find the distance from your (x,y) coordinate location to all other node locations (let's say they're defined by variables named allX and allY), then use min() to find out which one is closest to your target (x,y) point:
distances = sqrt((x - allX) .^ 2 + (y - allY) .^ 2);
[minDistance, indexOfClosestNode] = min(distances);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Christmas / Winter 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!