Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find angles between two vectors
Date: Wed, 23 Jan 2008 13:53:02 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 23
Message-ID: <fn7gru$7jd$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 1201096382 7789 172.30.248.35 (23 Jan 2008 13:53:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Jan 2008 13:53:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:447191



"Justin Morehouse":
<SNIP many many words...

> Hi there, I have a two vectors (3,5) and (5,6) and I was 
> wondering how do I get the angle between them in matlab.
> on paper I would multiply both vectors to get (15+30) to 
= 
> 45 and then square both (3,5) and (5,6) to get (9+25) and 
> (25+36). Then I would get the square root of both (34) 
and 
> (61) and multiply them together  and then divide 45 by 
that.
> Afterwhich  I would then use a trusty calc to do cos 
theta 
> of that, but how can math lab do that...

ML obeys your words... (as one of the solutions...)

     v1=[3,5];
     v2=[5,6];
     a=acosd(dot(v1,v2)/(norm(v1)*norm(v2)))

us