how to know the node number if i know the coordinates values

1 次查看(过去 30 天)
i have 100 nodes and plot on the graph randomly.each node are identify uniquely by node number.
I know the coordinate value of each node but i don't know the node number.
How to get the node number at particular X and Y coordinates
suppose i have value of X and Y is
X=42.3109 Y=21.2031
  2 个评论
Guillaume
Guillaume 2015-4-13
How are the nodes stored? Is it an N x 3 matrix where the columns are node number, x and y? Or something else?
Are the coordinates also stored rounded to 4 decimals or are they infinite precision? That will influence the way the coordinate search is performed.
singh
singh 2015-4-13
yes it coordinate store upto 4 decimals not a infinite precision

请先登录,再进行评论。

回答(1 个)

Guillaume
Guillaume 2015-4-13
It's not very clear what you are asking. Assuming you have an N x 3 matrix of nodes, x and y coordinates as such:
nodes = [1 15.2345 23.7891
2 23.1496 47.2365
3 42.3109 21.2031
4 16.7845 21.2031
5 42.3109 47.2145]; %column 1 = node number, 2 = x, 3 = y. rows are nodes
To find the node number for a given coordinate:
x = 72.3109;
y = 21.2031;
nodenumber = nodes(nodes(:, 2) == x & nodes(:, 3) == y, 1)
Note that this assumes that all numbers have been rounded to four decimals. Otherwise the comparison might fail if you obtained what is mathemically the same number through two different operations. Be aware that with floating point numbers (0.1 + 0.1 + 0.1) == 0.3 is false.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by