MATLAB: How to calculate distance between two ginput

graph

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 ?

Best Answer

%%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
Related Question