compute the unit vector given the angle

26 次查看(过去 30 天)
Hi guys,
How to compute the unit vector given the direction? Is there any function in matlab to do this task.
Thanks

回答(3 个)

Walter Roberson
Walter Roberson 2012-5-4
编辑:Walter Roberson 2018-12-10
For angle theta in radians,
%[x, y] = pol2cart(1, theta); %-> incorrect
[x, y] = pol2cart(theta, 1); %repaired
  3 个评论
Kye Taylor
Kye Taylor 2012-5-4
It's unusual that the inputs to the function don't match the "r-theta" convention that is used so often to identify the coordinate space.

请先登录,再进行评论。


Roger Stafford
Roger Stafford 2016-1-9
If vector 'v' points in the desired direction, then do this to make it a unit vector:
v = v/norm(v);

Kye Taylor
Kye Taylor 2012-5-4
Given the angle
theta
in radians (counter-clockwise is positive theta, theta = 0 points in the positive x-direction) your unit vector is
u = [cos(theta),sin(theta)]

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by