How to use the 2D array point in command window for calculating the total distance covered by the path

1 view (last 30 days)
Appearing in command window
waypoints =
2.0000 2.0000
2.1271 1.7164
4.3358 7.0825
7.3546 8.8141
10.7270 11.0068
11.0000 11.0000
command to fetch these coordinates and use them to calculate the total distance.

Accepted Answer

KSSV
KSSV on 10 Nov 2021
p = [2.0000 2.0000
2.1271 1.7164
4.3358 7.0825
7.3546 8.8141
10.7270 11.0068
11.0000 11.0000] ;
dp = diff(p) ;
d = cumsum(sqrt(dp(:,1).^2+dp(:,2).^2)) ;
d(end)

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox 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!