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

1 回表示 (過去 30 日間)
singh
singh 2015 年 4 月 13 日
回答済み: Guillaume 2015 年 4 月 13 日
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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by