How to find the linear distance between two points say (x,y) and (m,n) on an image?

13 ビュー (過去 30 日間)
Manoj Murali
Manoj Murali 2012 年 2 月 15 日
Hi..How can we find the linear distance between any two points on an image?Can we do this using any inbuilt function??or can this be done in any other way??plz help..
  2 件のコメント
Fernanda Rivera
Fernanda Rivera 2017 年 6 月 28 日
You can use the function pdist2 such as:
value=pdist2([x m],[y n],'euclidean'); %obtaining euclidean distance
Also if it works better for you, you can develop the formula:
value=sqrt((x-m)^2 + (y-n)^2); %euclidean distance.
María Peñas Leonor
María Peñas Leonor 2019 年 3 月 6 日
how could I do to show the line of that distance with plot?
Thanks

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

回答 (1 件)

Oliver Woodford
Oliver Woodford 2012 年 2 月 15 日
p1 = [x; y];
p2 = [m; n];
d = norm(p1 - p2);

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by