File Exchange

image thumbnail


version (2.25 KB) by M MA
Plot 2D velocity field.

1 Download

Updated 06 Oct 2005

View License


X, Y Arrows origin, N-D arrays
U, V Current components, N-D arrays
C, patches CData
'color', <color> line/patch color [ 'k' ]
'fill', [ {0} | 1 ], fill arrows tip
'tr', <val>, tip length with respect to intensity or absolute length if is a string [ <value> <value as string> {0.1} ]
'fi', <deg>, tip angle [ 30 ]
'z', <val>, z level, value or array size x, y, u and v [ 0 ]

The screenshot was created with:

[x,y] = meshgrid(-2:.2:2,-1:.15:1);
z = x .* exp(-x.^2 - y.^2);
[u,v] = gradient(z,.2,.15);
vfield(x,y,.3*u,.3*v,z), colorbar
axis equal

Cite As

M MA (2021). vfield (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)


The major improvement is the possibility of create the arrows as patches, not as lines, so that you can use the arrows to also show the vorticity field, or temperature, ... or simply the currents speed, as in the screenshot.
Moreover, you can also control the arrowhead scale or length.

Duane Hanselman

How is this an improvement over MATLAB's quiver function?

MATLAB Release Compatibility
Created with R12
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: vfield_color

Community Treasure Hunt

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

Start Hunting!