MATLAB Answers

Mahan Soltani

how to calculate degree between 3 points in MATLAB?

Asked by Mahan Soltani
on 1 Jan 2013

hi, how can i caculate degree between 3 points? i have position of X and Y of this three points. for more information please see this picture ( ) and download this file ( ).


In your image there are 4 points? Can you be more clear by giving an example of coordinates

yes,but i need degree that is red and (?degree). degree between two line(L-Knee point & Calcaneus) and (Calcaneus & 2th_MT). this image is a motion analys that i need degree of Ankle. some of data is : ( ) .



2 Answers

Answer by Roger Stafford
on 1 Jan 2013

Let row vectors P0 = [x0,y0], P1 = [x1,y1], and P2 = [x2,y2] be Calcaneus, L-Knee, and 2th_MT points, respectively. The angle shown in red in radians at Calcaneus point is:

 ang = atan2(abs(det([P2-P0;P1-P0])),dot(P2-P0,P1-P0));

Multiply by 180/pi to get degrees.

Roger Stafford


thanks a lot Roger, your code is true , and if you see the text file, i have very number and points. give me a code that import those text file to matlab and calculate Angel for any time ( row ). merc

No mohammad, I think you had better do that. That last vectorized formula I presented will have to suffice for my contribution to your effort.

Learning MATLAB on this time is hard and confusing for me. my field is Physical Therapy and i can't uderstand MATLAB very well...

Answer by Image Analyst
on 1 Jan 2013


on those post, 2 point are available, but i need 3 point which one of them isn't (0 0 0)! if you see image, you could uderstand...

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!