필터 지우기
필터 지우기

HOw can I change the size of the arrows

조회 수: 158 (최근 30일)
MAJED
MAJED 2014년 6월 24일
댓글: Cola 2021년 6월 15일
I did this code to plot a vector field, and i was wondering how can i change the size of the arrows?
t1 = linspace(-1,100,20);
y1 = linspace(-1,150,20);
[T,Y]=meshgrid(t1,y1);
DY=TribMod1(T,Y); DT=ones(size(DY));
scale = 1./sqrt(DT.^2+DY.^2);
quiver(T,Y, scale.*DT, scale.*DY);
axis([-1 100 -1 151])
ylabel('y')
xlabel('time (t)')
title('Direction field of function(1) with b=0.005')

채택된 답변

Star Strider
Star Strider 2014년 6월 24일
Use the 'AutoScaleFactor' property:
% CREATE DATA:
a = linspace(0,6*pi);
x = exp(-0.1*a) .* cos(a);
y = exp(-0.1*a) .* sin(a);
da = diff([0 a]);
dxda = diff([0 x]) ./ da;
dyda = diff([0 y]) ./ da;
% PLOT:
figure(1)
subplot(2,1,1)
h1 = quiver(x, y, dxda, dyda)
set(h1,'AutoScale','on', 'AutoScaleFactor', 2)
axis equal square
title('Arrows 2')
subplot(2,1,2)
h2 = quiver(x, y, dxda, dyda)
set(h2,'AutoScale','on', 'AutoScaleFactor',0.5)
axis equal square
title('Arrows ½')
produces:
  댓글 수: 1
Cola
Cola 2021년 6월 15일
How about the size of the arrows in streamslice. Thanks.

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

추가 답변 (1개)

Geoff Hayes
Geoff Hayes 2014년 6월 24일
From your code, grab the quivergroup handle that is returned from the quiver function
h = quiver(T,Y, scale.*DT, scale.*DY);
You can change the size (width) of the arrows from its default value of 0.5 as follows
set(h,'LineWidth',2)
Note that you could also do this at the line quiver(T,Y, scale.*DT, scale.*DY,'LineWidth',2);.
Try this and see what happens!

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by