how to scale arrows

4 次查看(过去 30 天)
MAJED
MAJED 2014-6-24
回答: Adam Danz 2024-4-26
I have this code for a vector field, the arrows keep getting crazier no mater what i do, can some one plese tell me how do i make them look nice and organized and same size
t1 = linspace(-1,500,10);
y1 = linspace(140,160,10);
[T,Y]=meshgrid(t1,y1);
DY=TribMod4(T,Y); DT=ones(size(DY));
scale = 1./sqrt(DT.^2+DY.^2);
p1=quiver(T,Y, 0.01.*DT, 0.001.*DY);
set(p1,'AutoScale','on', 'AutoScaleFactor', 0.08)
axis([-5 500 140 160])
hold on
[t,y]=ode45(@TribMod4,[0:0.51:900],147.971);
plot(t,y,'r')
ylabel('y')
xlabel('time (t)')
title('Direction field of function(2) with b=0.005')
thanks

回答(2 个)

Star Strider
Star Strider 2014-6-25
You can turn autoscaling off by commenting the ‘set’ statement so it will not execute and instead calling quiver with:
quiver(x, y, dxda, dyda, 0)
The arrow lengths are controlled by the (u,v) vectors in the quiver documentation (here the (dxda,dyda) vectors), so while you can turn off autoscaling (that normally keeps the arrows from overlapping), according to the documentation and some of my experiments, you would have to control their lengths with (u,v).

Adam Danz
Adam Danz 2024-4-26
Quiver scaling can be tough to understand. We recently added the ScaleFactor property (R2024a) to help out. See this answer for 3 ways to control the scale of quiver arrows.

类别

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