How to Display Velocity Vectors in MATLAB Using quiver()

By Jim Sizemore, John Paul Mueller

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.

  1. Type XSource = [1, 1, 1, 1, 1, 1]; and press Enter.

  2. 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.

  3. Type USource = [1, 2, 3, 4, 5, 6]; and press Enter.

  4. 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.

  5. Type quiver(XSource, YSource, USource, VSource); and press Enter.

    You see a quiver plot.

    image0.jpg