how to code in matlab struct form

how to code in matlab struct form to find the distances of nodes randomly selected from a randomly distrbuted nodes. pliz help
in the given code some nodes are selected based on some random number generated by nodes from i nodes and one struct matrix is formed for the new nodes and want to find distances for those new selected nodes. pliz help

 採用された回答

KSSV
KSSV 2019 年 2 月 1 日

0 投票

Read about pdist and pdist2. If you have coordinates(x1,y1) and (x2,y2) you may straight away use distance formula:
d = sqrt((x2-x1).^2+(y2-y1).^2)

3 件のコメント

Guillaume
Guillaume 2019 年 2 月 1 日
You can also use hypot which supposedly is more reliable for extreme cases than using sqrt(dx.^2 + dy.^2) directly.
d = hypot(x2-x1, y2-y1);
madhan ravi
madhan ravi 2019 年 2 月 1 日
編集済み: madhan ravi 2019 年 2 月 1 日
+1 Guillaume! , hypot's accuracy is higher.
rem ng
rem ng 2019 年 2 月 2 日
thanks all for your help !!!!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

質問済み:

2019 年 2 月 1 日

コメント済み:

2019 年 2 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by