필터 지우기
필터 지우기

Plot multiple quiver keeping arrows magnitude proportion

조회 수: 10 (최근 30일)
Marius Marinescu
Marius Marinescu 2021년 7월 14일
댓글: Marius Marinescu 2021년 9월 9일
Hello! I have a simple question I am not able to solve properly. I will simplify the problem to the following:
Consider two sets of vector field data:
  • F1=(x,y,u,v)
  • F2=(x,y,2*u,2*v).
When I plot these data, the size of the arrows coming from F2 are the same as the ones coming from F1, despite the fact that they are actually doble length.
If I want quiver to autoscale the arrows, but to mantain the magnitue proportion between arrows for different data sets (by different calls to quiver), what is the best way of doing it?
An test code to show this issue is:
n=30;
x=randn(n,1);
y=randn(n,1);
u=randn(n,1);
v=randn(n,1);
quiver(x,y,u,v,'b');
hold on
quiver(x,y,2*u,2*v,'r')
legend('F1','F2')
hold off

답변 (1개)

Hrishikesh Borate
Hrishikesh Borate 2021년 7월 19일
편집: Hrishikesh Borate 2021년 7월 19일
Hi,
By default, the quiver function shortens arrows so they do not overlap. To disable automatic scaling so that arrow lengths are determined entirely by U and V, set the scale argument to 0. Following code demonstrates the same.
quiver(x,y,u,v,0,'b');
hold on
quiver(x,y,2*u,2*v,0,'r')
legend('F1','F2')
hold off
For more information, refer quiver.
  댓글 수: 2
Marius Marinescu
Marius Marinescu 2021년 7월 19일
First of all thanks for your answer.
My question is slightly different. I want to keep the size proportion between "arrows" (for different calls to quiver) but at the same time let Matlab scale automatically the arrows so they do look good and have no overleap.
I have different data sets that can vary in magnitude, so in the way you asnwered me I have to guess a "good scale factor" for each time I use different data.
So ideally, I would like Matlab to scale automatically the data when I first call to quiver and after using hold on and call quiver again to add more (similar) data, I want that Matlab keeps or use the same scale factor as in the first one.
I think by the way is quiver programed now, it is not usefull to use hold on, since arrows are scaled automatically and independently for each call to quiver making arrows size incomparable.
Lastly, I have a related question that may help me to solve this issue. Is it possible to know the automatic scaling factor Matlab uses after executing quiver?
Marius Marinescu
Marius Marinescu 2021년 9월 9일
Is it clear? Any help?

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

카테고리

Help CenterFile Exchange에서 Condensed Matter & Materials Physics에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by