Borrar filtros
Borrar filtros

Quiver plot - vector direction

2 visualizaciones (últimos 30 días)
Vignesh
Vignesh el 5 de Feb. de 2024
Comentada: Vignesh el 7 de Feb. de 2024
Hi,
I am trying to plot quiver plot of 2d data and the generated quiver plot is not pointing in the direction of second dataset (x2,y2) from first dataset (x1,y1). Please let me the error I am committing in displaying the plot.
Thanks,
Vignesh
x1 = [5 5.5 6 6.5 7 7 7 6.5 6 5.5 5 5 5 ];
y1= [5 5 5 5 5 5.5 6 6 6 6 6 5.5 5];
plot (x1,y1)
hold on
xlim([-20 20])
ylim([-20 20])
x2 = [4.19 5.26 6.00 6.74 7.81 7.96 7.81 6.74 6.00 5.26 4.19 4.04 4.19];
y2 = [4.19 4.05 4.08 4.05 4.19 5.50 6.81 6.95 6.92 6.95 6.81 5.50 4.19];
plot(x2,y2)
hold on
quiver(x1,y1,x2,y2)

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 5 de Feb. de 2024
Your U and V values are all positive, so all quivers will point up and to the right.
I think you want U and V to be the difference between 2 and 1, and not the location of 2.
x1 = [5 5.5 6 6.5 7 7 7 6.5 6 5.5 5 5 5 ];
y1= [5 5 5 5 5 5.5 6 6 6 6 6 5.5 5];
plot (x1,y1)
hold on
x2 = [4.19 5.26 6.00 6.74 7.81 7.96 7.81 6.74 6.00 5.26 4.19 4.04 4.19];
y2 = [4.19 4.05 4.08 4.05 4.19 5.50 6.81 6.95 6.92 6.95 6.81 5.50 4.19];
plot(x2,y2)
quiver(x1, y1,x2-x1,y2-y1)
  1 comentario
Vignesh
Vignesh el 7 de Feb. de 2024
Thanks for pointing out the reason why the vectors are not directing as expected.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Vector Fields en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by