Calculate distance between 2 points using array
7 views (last 30 days)
Show older comments
Antonin Ponchon De Saint Andre
on 1 May 2021
Commented: Matt J
on 1 May 2021
Hi, how can I find the distance between 2 points using this equation? eqn=sqrt{{X_{i+1}-X_{i}}^2+{{Y_{i+1}-Y_{i}}^2}};
I need to use a matrix that is defined by the user (it cannot be changed) so any coordinates can be entered.
numberOfCoord=input('Please Input the Number of Coordinates:');
if numberOfCoord < 4
disp (['Error']);
return
end
data = zeros(2, numberOfCoord);
for i= 1:1:numberOfCoord
data(1, i)=input('Please Enter X Coordinate:');
data (2, i)=input ('Please enter Y Coordinate:');
end
if i < 0
disp (['Error']);
return
end
any tips or help to solve this would be great thanks :))
2 Comments
Turlough Hughes
on 1 May 2021
This code requires atleast 4 points, are you looking for distances from a given point to every other point?
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Earth, Ocean, and Atmospheric Sciences in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!