Effacer les filtres
Effacer les filtres

Quiver plot - vector direction

2 vues (au cours des 30 derniers jours)
Vignesh
Vignesh le 5 Fév 2024
Commenté : Vignesh le 7 Fév 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)

Réponse acceptée

Cris LaPierre
Cris LaPierre le 5 Fév 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 commentaire
Vignesh
Vignesh le 7 Fév 2024
Thanks for pointing out the reason why the vectors are not directing as expected.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Vector Fields dans Help Center et File Exchange

Tags

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by