View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
2D Vector Field Visualization

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

2.0 | 1 rating Rate this file 8 Downloads (last 30 days) File Size: 3.15 KB File ID: #29487 Version: 1.0
image thumbnail

2D Vector Field Visualization


Nicholas Howe (view profile)


Two functions that create visualizations of 2D vector fields

| Watch this File

File Information

The files in this package comprise two Matlab functions that create
visualizations of 2D vector fields.

cquiver renders a vector field as a grid of unit-length arrows. The arrow direction indicates vector field direction, and the color indicates the magnitude. Color is taken from the current colormap.

vfcolor renders a vector field as a grid of colors. Hue indicates the field direction, and saturation indicates the magnitude. The current implementation uses a fixed color coding.


Ncquiverref inspired this file.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
17 Mar 2016 Eric

Eric (view profile)

cquiver works fine.

vfcolor fails.

Subscript indices must either be real positive
integers or logicals.

Error in vfcolor (line 64)
img1(:) = c(h1,1,:);

20 Jun 2014 Nicholas Howe

Nicholas Howe (view profile)

As implemented, cquiver and vfcolor can only display a rectangular grid of vectors. Thus the quiver functionality you are looking for is not available. Sorry! I'll consider whether it can be added in a future version.

Comment only
20 Jun 2014 fabrizio

Dear Nicholas,
I have a problem with using cquiver and vfcolor. I have a map of vectors that I normally display with quiver by giving it as an imput the x and y position of each vector and the x and y components (say quiver(xcoord, ycoord, xcomp, comp)). Rather then the standard quiver plot, I wish to colorcode this map of vectors. What should I give as an input to vfcolor or cquiver?

Comment only
11 Sep 2013 Christopher

it works, thank you :)

Comment only
16 Aug 2013 Nicholas Howe

Nicholas Howe (view profile)

I guess it's confusing that the usage for cquiver is slightly different from quiver. Sorry about that!

If I understand your example properly, `of` represents the optical flow you wish to display as a 2D array of complex numbers. In that case you should be able to call cquiver like this:


Comment only
16 Aug 2013 Christopher

can you give me an working example of the cquiver() function? i don't know how to handle the input arguments.

formally I used Matlabs quiver() function like this:

%read a single frame of a Video file

im = step(hVideoSrc);

%create a rectangular grid

[X Y] = meshgrid(1:1:size(im, 2), 1:1:size(im, 1));

% compute optical flow for the video
%Horizontal and vertical components in %complex form

of = step(hof,im);

%plot a 2-d vector Field


This returns a Quiver Plot of the Optical flow between two frames of the Video.
But when I replace the quiver() function With the cquiver function it just returns me the Colorbar, and nothing else.

Comment only

Contact us