Rotating a Vector
Afficher commentaires plus anciens
Hello! I am wondering if anyone has an elegant way to rotate a vector by a specified degree.
For example, I have a vector that goes from (0,0) to (-1,-12). I want to rotate this vector by 5 degrees, incrementally until it reaches the x-axis.
Obviously this can be done from the math, but I wonder if anyone has a nicer way of doing this.
Thank you in advance!
Amina
Réponse acceptée
Plus de réponses (3)
Sean de Wolski
le 8 Juil 2011
Unless I'm missing something just use the rotation matrix:
v = [-1 -12];
theta = 5;
R = [cosd(theta) -sind(theta); sind(theta) cosd(theta)];
vR = v*R;
quiver(0,0,v(1),v(2))
hold on
quiver(0,0,vR(1),vR(2))
1 commentaire
A
le 20 Juil 2011
Sayyed Ahmad Khadem
le 26 Déc 2018
0 votes
Hi all,
I read this blog, and I have similar problem. I would be thankful to kindly give me some clues if you know.
Suppose that we have a vector field in y-x plane, let's consider following example:
Vector Field : Vf = [u, v]
u=x
v=y

Now, I need to revolve the given vector field around the center of plot (i.e. [0 0]). Does anyone can provide some nice solution?
Thanks in advance,
1 commentaire
Adam Danz
le 16 Avr 2020
You can flip the direction of the quiver arrows by using the quiver handle or by flipping the vector component prior to producing the quiver plot.
h = quiver(x,y,u,v);
quiverRotate(h)
% or
[Ur,Vr] = quiverRotate(u,v);
quiver(x,y,Ur,Vr)
wenhao li
le 11 Jan 2019
0 votes
Have you solved this problem? I met this problem, too.
1 commentaire
Sayyed Ahmad Khadem
le 11 Jan 2019
Hi Wenhao,
No one has suggested a viable approach yet ! :-( I am still struggling !
Catégories
En savoir plus sur Polar Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!