How to rotate a quiver object in matlab

조회 수: 6 (최근 30일)
Ricardo Ferreira
Ricardo Ferreira 2015년 6월 9일
댓글: Adam Danz 2020년 4월 16일
I have a quiver object like this
q = quiver(x,y,u,v);
and then I use rotate to rotate it, but nothing happens
rotate(q,[0 0 1],180);
the command above works on a surf object, but not in a quiver one,why?
Thank you!
  댓글 수: 1
Adam Danz
Adam Danz 2020년 4월 16일
If you're rotating the vector about it's base so that (x,y) do not change but the direction of the vector changes, you can use quiverRotate() from the file exchange.
Example:
[Ur, Vr] = quiverRotate(U, V, 180, 'deg');
quiver(x, y, Ur, Vr)
% Or use the quiver handle
quiverRotate(q, 180, 'deg')

댓글을 달려면 로그인하십시오.

채택된 답변

Mike Garrity
Mike Garrity 2015년 6월 9일
The rotate command actually modifies the data of the graphics object, and it doesn't know how to modify all of the different types of graphics objects. The quiver one, in particular is a bit tricky because some of the data represents directions instead of positions.
A more robust way to do this is to use the hgtransform command . It would look something like this:
g = hgtransform;
quiver(x,y,u,v,'Parent',g)
set(g,'Matrix',makehgtform('zrotate',pi/4))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by