Home / Expert Answers / Computer Science / angle-between-vectors-the-angle-0-lt-theta-lt-180-deg-between-two-n-dimensional-real-vectors-u-pa147

(Solved): Angle Between Vectors The angle 0<=\theta <=180\deg between two n-dimensional real vectors u, ...



Angle Between Vectors The angle

0<=\theta <=180\deg

between two

n

-dimensional real vectors

u,vinR^(n)

can be determined through the relationship

cos\theta =(u*v)/(||u||||v||)

, where

u*v=u^(T)v=\sum_(i=1)^n u_(i)v_(i)

is the standard dot product and

||u||=\sum_(i=1)^n \sqrt(u_(i)^(2))

is the Euclidean (or

L_(2)

) norm. Write a function vectorAngle( ) which takes as input: u,

n\times 1

double array v,

n\times 1

double array and returns as output: theta, the angle in degrees between

u

and

v

(note that the given equation is for

cos(\theta )

) Assume

u

and

v

are non-zero vectors. Do not use loops in your solution. Example:

u=[1;0;0] v=[0;1;1] theta = vectorAngle (u,v)

Output: theta

=

90 IN MATLAB please!



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe