How to correctly draw 2D vectors?

10 visualizaciones (últimos 30 días)
Miguel Viegas Leal
Miguel Viegas Leal el 26 de Feb. de 2016
Respondida: Star Strider el 26 de Feb. de 2016
Hey there,
I want to match the velocity vector arrows with the blue line of the graphic. The velocity vectors should have the same magnitude as the points in the blue line, but I can't understand why they don't match.
I would like something like this:
But, I all got is this:
This is my code:
% X=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] %position on x axis
Y=[-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7]; %position on y axis
U=[2.19 3.79 8.00 13.15 16.64 16.97 17.11 17.25 17.34 17.25 13.27 8.00 3.58 1.79 0]; %velocity on x axis
V=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] %velocity on y axis
hold on;
plot(U,Y);
grid on
quiver(X,Y,U,V);
hold off

Respuestas (1)

Star Strider
Star Strider el 26 de Feb. de 2016
Add a ‘0’ to the quiver call to turn off the scaling:
quiver(X,Y,U,V,0)
That produces the plot you want. See the documentation on quiver for details.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by