I am new to Matlab. Trying to use quiver to plot a velocity field. This is my code that gets to the plot but doesn't show any arrows.
[x,y] = meshgrid(0:0.2:5,0:0.2:5);
u = 2./x;
v = 2.*y./(x.^2);
figure
quiver(x,y,u,v)

 채택된 답변

KSSV
KSSV 2019년 3월 1일
편집: KSSV 2019년 3월 1일

0 개 추천

As the grid starts from 0 and you have used this zero in the reciprocal to get (u,v) you will get inf in the u,v.; quiver uses maximum value of u and v to scale the arrows and plot. Try to repalce inf with some other value or avoid zero.
[x,y] = meshgrid(1:0.2:5,1:0.2:5);
u = 2./x;
v = 2.*y./(x.^2);
figure
quiver(x,y,u,v,1,'r')

댓글 수: 1

Worked perfectly. Learned something about the scaling too. Thank you!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2019년 3월 1일

댓글:

2019년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by