Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find angles between two vectors
Date: Wed, 6 May 2009 05:38:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 10
Message-ID: <gtr7np$59d$1@fred.mathworks.com>
References: <fn7egt$447$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1241588281 5421 172.30.248.35 (6 May 2009 05:38:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 6 May 2009 05:38:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1196217
Xref: news.mathworks.com comp.soft-sys.matlab:537779


what I did is the following:

% I used "atand" b/c I want it in DEG, but you can remove the "d" to have RAD.
theta = atand((y(2)-y(1))/(x(2)-x(1)));

%This gives me correct values for x(2)>x(1), but for x(2)<x(1), I included the 
% following "if" statement:
angle = theta+(x(2)<x(1))*180

This gave me what I wanted, which is the angle between between two vectors.