How to get the (only one) nearest/closest node in the network

4 ビュー (過去 30 日間)
sarah nik
sarah nik 2013 年 7 月 18 日
Hi, I have problem to get the nearest node. This program connect the source node to all other nodes that are below or equal to 'radius'(i set this radius value to 10 m). I just need one, that is the closest to this source node. Please help me. this is the code:
for i=1:No_Nodes
XDiff_Source(i)=Node_Loc(i,1) - Source_Loc(1,1);
YDiff_Source(i)=Node_Loc(i,2) - Source_Loc(1,2);
Distance_Source_Node(i)=(XDiff_Source(i)^2 + YDiff_Source(i)^2)^(0.5);
if Distance_Source_Node(i)<= radius
line([Source_Loc(1,1) Node_Loc(i,1)],[Source_Loc(1,2) Node_Loc(i,2)]);
plot(Node_Loc(i,1), Node_Loc(i,2), 'pg'); hold on
end
end
thank you.

回答 (1 件)

Sean de Wolski
Sean de Wolski 2013 年 7 月 18 日
doc knnsearch %?
  2 件のコメント
sarah nik
sarah nik 2013 年 7 月 18 日
i am sorry, how to use this function?
Jan
Jan 2013 年 7 月 18 日
Did the documentation leave any open questions?
help knnsearch
doc knnsearch

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by