Plot multiple quiver keeping arrows magnitude proportion

14 次查看(过去 30 天)
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by