How to calculate distance between two ginput?

1 次查看(过去 30 天)
hai friends i have to calculate distance between two ginput points and also how to calculate angle between 4 ginput.
how to calculate its length?
And how to calculate angle for this ?

采纳的回答

Birdman
Birdman 2017-11-10
编辑:Birdman 2017-11-10
%%distance
[x,y]=ginput(2)
len=sqrt((y(2)-y(1))^2+(x(2)-x(1))^2)
%%angle
[x,y]=ginput(4);angle=zeros(1,floor(length(x)/2));
for i=1:floor(length(x)/2)
angle(i)=atan((y(i+2)-y(i+1))/(x(i+2)-x(i+1)));
end
  4 个评论
VALARMATHY K
VALARMATHY K 2017-11-10
Thank you..., but i am not getting value in centimetre, but your first answer helps me.
Birdman
Birdman 2017-11-10
You should not expect to get an answer in centimeter because you can not define any unit for the variable. You just assume that it is centimeter.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile 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