How to correctly draw 2D vectors?

조회 수: 10 (최근 30일)
Miguel Viegas Leal
Miguel Viegas Leal 2016년 2월 26일
답변: Star Strider 2016년 2월 26일
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

답변 (1개)

Star Strider
Star Strider 2016년 2월 26일
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.

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by