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?
> 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...)
"us " <us@neurol.unizh.ch> wrote in message
<fn7gru$7jd$1@fred.mathworks.com>...
> "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
The same question was posted and available at the following
address
"Justin Morehouse" <norman_batez@MSN.com> wrote in message <fn7egt
$447$1@fred.mathworks.com>...
> 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?
>
> Thanks!
------------
Another possible solution:
where ang is measured in radians. (Multiply by 180/pi to get degrees.)
This method has a slight advantage over the arccosine method. The acos
function suffers an inherent loss of accuracy near angles 0 and pi, whereas
the atan2 function maintains full accuracy for such cases. (Make a plot of the
acos curve from -1 to +1 to see why.)
It is important to distinguish between two possible definitions of an angle
between vectors in the x-y plane. Above, the angle is considered as a non-
negative quantity lying between 0 and pi. It can also be defined as the angle
measured counterclockwise from the first vector to the second one, which in
general would be an angle ranging from 0 to 2*pi, or else from -pi to +pi
with clockwise being considered negative. For this latter meaning one would
remove the 'abs' in the above expression.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.