How to Display Velocity Vectors in MATLAB Using quiver()
In MATLAB, a quiver plot shows the velocity vectors defined by the components u and v at points described by the coordinates defined by x and y. (Read more about the composition of velocity vectors.) When you don’t specify x and y, the plot is created using equally spaced values along the x-axis with a value of y = 1. The following steps help you create a quiver plot.
Type XSource = [1, 1, 1, 1, 1, 1]; and press Enter.
Type YSource = [1, 1, 1, 1, 1, 1]; and press Enter.
These two vectors define the x/y coordinate pairs used as the starting point for the vectors. In this case, all the vectors have the same origin of 1, 1.
Type USource = [1, 2, 3, 4, 5, 6]; and press Enter.
Type VSource = [6, 5, 4, 3, 2, 1]; and press Enter.
These two vectors define the positions of the velocity vectors within the x-y plane.
Notice that the four vectors are the same size. Whenever you create a quiver plot, the vectors must be the same size because they act in pairs to create coordinates.
Type quiver(XSource, YSource, USource, VSource); and press Enter.
You see a quiver plot.