I have to a matrix n x 2 in which each row represent a point in a Cartesian space in X and Y. The distance I have to calculate is between a row and its follower so at the end I have an array (n-1) x 1. I ve coded a simply function but since n = 50 000 it takes a lot of time to compute. How to speed up the entire process?
That s my function:
function [Dist] = Distances(A)
Dist(i,1)= sqrt((A(i+1,1)- A(i,1))^2 + (A(i+1,2)- A(i,2))^2)