compute the unit vector given the angle

9 vues (au cours des 30 derniers jours)
zhang
zhang le 4 Mai 2012
Hi guys,
How to compute the unit vector given the direction? Is there any function in matlab to do this task.
Thanks

Réponses (3)

Walter Roberson
Walter Roberson le 4 Mai 2012
Modifié(e) : Walter Roberson le 10 Déc 2018
For angle theta in radians,
%[x, y] = pol2cart(1, theta); %-> incorrect
[x, y] = pol2cart(theta, 1); %repaired
  3 commentaires
Walter Roberson
Walter Roberson le 4 Mai 2012
Urrr, yes.
Kye Taylor
Kye Taylor le 4 Mai 2012
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.

Connectez-vous pour commenter.


Roger Stafford
Roger Stafford le 9 Jan 2016
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 le 4 Mai 2012
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)]
  1 commentaire
jack
jack le 9 Jan 2016
How can you apply your answer to higher dimensions?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by