Reputation: 387
I am struggling with the quiver function in MATLAB. The thing is, that I want the directions of the arrows be shifted by 90 degrees. So when the derived angle is zero degrees, the vector arrows in the plot should point downwards instead of to the right as pre-defined in the quiver function.
Any suggestions, how to solve this problem?
Upvotes: 1
Views: 1163
Reputation: 112679
To get a 90-degree turn, you only have to interchange u
and v
and add a minus sign.
Consider the following example:
[x y] = ndgrid(-1:.2:1);
u = 1+x - 2*y.^2;
v = -x.^2 - y;
Normal figure:
quiver(x,y,u,v) %// normal
axis([-1.5 1.5 -1.5 1.5])
Vectors turned 90 degrees:
quiver(x,y,v,-u) %// 90 degree turn. quiver(x,y,-v,u) for turning the other way
axis([-1.5 1.5 -1.5 1.5])
Upvotes: 1
Reputation: 21563
It turns out that this can be surprisingly simple.
I believe you are looking for this:
camroll(90)
Just make your quiver plot and then execute this command.
Upvotes: 0