How do I calculate the distance between x1,x2,y1,y2?
2 views (last 30 days)
Show older comments
I have an excel datasheet and I want to calculate the distances using a simple distance formula (square root of (x2-x1)^(2)+(y2-y1)^(2)). How can I open it in Matlab and how can i calculate it in Matlab?

0 Comments
Answers (1)
Image Analyst
on 4 Jul 2016
Try this:
numbers = xlsread(filename)
x1 = numbers(:, 4); % Extract column 4
y1 = numbers(:, 5); % Extract column 5
x2 = numbers(:, 6); % Extract column 6
y2 = numbers(:, 7); % Extract column 7
distances = sqrt((x2-x1).^2 + (y2-y1).^2);
2 Comments
Image Analyst
on 4 Jul 2016
Edited: Image Analyst
on 4 Jul 2016
Try
numbers=xlsread('DelmarvaS_SVA_LT.xlsx')
and distances does give you the distance for each row in the workbook.
See Also
Categories
Find more on Spreadsheets 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!