Draw a line between two points on plotted data and compute its length

8 ビュー (過去 30 日間)
Asatur Khurshudyan
Asatur Khurshudyan 2020 年 5 月 21 日
コメント済み: Asatur Khurshudyan 2020 年 5 月 22 日
Hi All,
Suppose we have a set of 2D points:
px = [1, 2, 5];
py = [1, 2, 1.5];
When we plot these points, we get 3 distinct points:
plot(px, py, 'r*')
Is it possible to draw a line connecting any two of those directly on the figure and measure the Euclid distance between them?
Regards
Edit
I don't need to PLOT a line. I need to click at one point and move the mouse to the second point to draw the line and measure the Euclidean distance between them,.

採用された回答

KSSV
KSSV 2020 年 5 月 21 日
px = [1, 2, 5];
py = [1, 2, 1.5];
x = [px(1) py(1)] ;
y = [px(2) py(2)] ;
z = [px(3) py(3)] ;
plot3(x,y,z,'r')
d = sqrt(diff(x)^2+diff(y)^2+diff(z)^2)
  4 件のコメント
Asatur Khurshudyan
Asatur Khurshudyan 2020 年 5 月 22 日
Thanks, drawline is exactly what I was searching for.
Asatur Khurshudyan
Asatur Khurshudyan 2020 年 5 月 22 日
It could be more useful if you edit the answer and add the drawline there.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by