MATLAB: Calculate the angle between multiple points

angles

I have a matrix A contain x values in the first column and y values in the second column. I want to calculate the angle between vectors.

Best Answer

The ACOS and the corresponding ASIN approchs are numerically instable near to multiples of pi (half). Better use the more accurate ATAN2 method:
angle = atan2(norm(cross(v1,v2)), dot(v1,v2));