Let Q be a nx2 vector, which contains n (2-dimensional) coordinates. I want to calculate the distance between the i and i+1-th coordinate for all integers i in the vector and then add it up.
I came up with the following:
syms d
symsum(sqrt(sum((Q(d,:)-Q(d+1,:).^2))),d,1,n-1);
However, I get the following error:
??? Error using ==> sym.sym>notimplemented at 2653
Function 'subsindex' is not implemented for MuPAD symbolic objects.
Error in ==> sym.sym>sym.subsindex at 1359
notimplemented('subsindex');
Error in ==> test4 at 4
symsum(sqrt(sum((Q(d,:)-Q(d+1,:).^2))),d,1,n-1);
Alternatively I could of course use a for loop, but I suspect that this is probably not the neatest and quickest solution.
If I am reading this correctly you just want the Euclidean distance between pairs of points in your nx2 matrix. So all you have to do is this: