No Arrows showing in plot When using quiver

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)

 Respuesta aceptada

KSSV
KSSV el 1 de Mzo. de 2019
Editada: KSSV el 1 de Mzo. de 2019
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 comentario

Andrew Nelson
Andrew Nelson el 1 de Mzo. de 2019
Worked perfectly. Learned something about the scaling too. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Vector Fields en Centro de ayuda y File Exchange.

Productos

Versión

R2018b

Etiquetas

Preguntada:

el 1 de Mzo. de 2019

Comentada:

el 1 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by