shortest distance between two points

hi All,
I am trying to calculate a shortest distance between two points.
lets say, an object moved from coordinates (3,4) to ( 7,7).
then distance between these two points can be calculated using simple pythagoras theoram
d=(7-3)^2 + (7-4)^2= 5
I am also trying to calculate shortes distance between these two coordiantes.
if I am trying ds= (7-3)+(7-4)= 7
but ds can not a displacement, as displacement is the shortest distance between two points.
any one can help please?

 采纳的回答

Matt J
Matt J 2012-10-2
d=norm([7,7]-[3,4])
ds=norm([7,7]-[3,4],1)

3 个评论

Thanks Matt, for your response.
let me share here a complete problem.
my data is being packed in a matrix.
e.g.
cX=fb.data.cX; cY=fb.data.cY;
% % distance travelled between each frame dX=diff(cX); dY=diff(cY); adX=abs(dX); adY=abs(dY); a=adX.^2; b=adY.^2;
% use pythagoras CS=plus(a,b); Cq=sqrt(CS); % % % calculate total distance travelled in full box unit (=cm in 1cm box chamber) totaldistance=sum(Cq);
if what I have calculated is the distance travelled, then how should I calculate the displacement and total displacement using X and Y coordinates?
Your help will be really appreciated
Isn't it adX+adY? If not, I need we'll need a better example of what you want.
Yes you are right, but I just realised that using pythagoras theroam I was allready calculating displacement or shortest distance between two point. Using adX+adY will give me actual distance travelled.
Thanks for your input Matt.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by