Say I have a vector of x values, and a vector of y values. I would like to write a function to calculate the distance between successive points. I know how to do this in a loop, like the snippet given below.
for i = 1:1:size(x) - 1 distance(i) = sqrt((x(i) - x(i + 1)) ^ 2 + (y(i) - y(i + 1)) ^ 2)end
Is there a way to do this without the loop?
Best Answer