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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169408/image.png)
how to calculate its length?
And how to calculate angle for this ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169409/image.png)
0 件のコメント
採用された回答
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 件のコメント
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 Center および 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!