Program to calculate Distance between points and fixed point

I have three points A(000),B(111),C(222) and one fixed position P(333). I want make program to calculate the distance from A, B and C to point P using for loops. Appreciate if have some idea?

 採用された回答

Matt J
Matt J 2021 年 8 月 5 日

0 投票

Use pdist2
distances=pdist2([A;B;C],P)

4 件のコメント

Yadu Bhusal
Yadu Bhusal 2021 年 8 月 5 日
Appreciate your answer. But I was given task using for loop I need the above point A,B and C in single array and from these points i have to calculate distance to fixed point P using for loop.
Matt J
Matt J 2021 年 8 月 5 日
pdist2.m has for-loops inside it.
Yadu Bhusal
Yadu Bhusal 2021 年 8 月 5 日
Thank you. And can angle made by A,B,C to P be calculated using these distances and these points or distances?
Matt J
Matt J 2021 年 8 月 5 日
No, they cannot.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2021 年 8 月 5 日

コメント済み:

2021 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by