How to calculate distance between two ginput?

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 ?

 Risposta accettata

Birdman
Birdman il 10 Nov 2017
Modificato: Birdman il 10 Nov 2017
%%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 Commenti

Thank you please tell me how to measure its length in centimetre
Use this:
m=input('Enter upper x limit in any unit(ex. centimeters)\n');
n=input('Enter upper y limit in any unit(ex. centimeters)\n');
c=line;c.Parent.XLimMode='Manual';c.Parent.YLimMode='Manual';c.Parent.XLim=[0 m];c.Parent.YLim=[0 n];
[x,y]=ginput(2);
len=sqrt((y(2)-y(1))^2+(x(2)-x(1))^2);
c=plot(x,y)
Thank you..., but i am not getting value in centimetre, but your first answer helps me.
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Display Image in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by