How do I calculate the angle between a vector and a matrix directly in MATLAB 7.13 (R2011b)?
5 views (last 30 days)
Show older comments
I have a vector 'v' which is 3x1 in dimension and a matrix 'A' which is 3Xn in dimension where 'n' is any large number > 1.
Accepted Answer
MathWorks Support Team
on 22 Dec 2011
Currently there is no way to directly compute the angle between a vector and a matrix.
Calculating the angle between vectors involves computing the dot product and dividing by the norm of both the participating vectors. The existing NORM functionality does not operate individually on columns of a matrix.
Please find the function NORMCOL attached below, which can be used to compute the norm of a matrix along columns. Using NORMCOL one can compute the angle as follows:
To find the angle in degrees, you may run the following command on the matrix A (3 X n columns) and vector v (3 X 1 single column):
Angles = acos((v'*A)./(norm(v).*normcol(A)))*(180/pi)
0 Comments
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!