Plotting arrows specified by azimuth

조회 수: 3 (최근 30일)
John
John 2011년 6월 21일
I am trying to construct a "tadpole" plot which illustrates a vector specified by its azimuth measured clockwise from north. Here is some code that does the task:
xpos=unifrnd(0,10,15,1); % X location
ypos=unifrnd(0,10,15,1); % Y location
azi=unifrnd(0,360,15,1); % Vector azimuth (north = 0)
Ecpt=sin(azi*pi/180); % East component of vector
Ncpt=cos(azi*pi/180); % North component of vector
quiver(xpos,ypos,Ecpt,Ncpt)
The problem I'm encountering, however, is that if I rescale the plot axes (by zooming in for example), the orientation of the vector changes. You can see this in the case that the horizontal axis is stretched:
p=axis;
axis([p(1) p(2)*5 p(3) p(4)]);
How could I specify the vectors so that (for example) a vector corresponding to an azimuth of 70 deg. always appears in the plot at a 20 deg. angle to the horizontal axis no matter how I change the axes or zoom in?

답변 (1개)

Patrick Kalita
Patrick Kalita 2011년 6월 21일
I think in order to keep the angles consistent you can't necessarily change the axes limits completely arbitrarily, because the quiver arrows are essentially static once they are drawn in an axes. They don't dynamically update with changes to the limits.
Your best bet here might be to use axis equal.
  댓글 수: 1
John
John 2011년 6월 21일
Thanks, Patricia.
I should have mentioned in my posting that the x-y axes can't easily be scaled using 'axis equal', unfortunately (x is in degrees from 0-90, and y is in meters). I'm going to keep working on this problem and will update the posting if I have a break-through!
Thanks again,
John.

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

카테고리

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