how to scale arrows

조회 수: 6 (최근 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에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by