File Exchange

image thumbnail

quiver3d

version 1.0 (4 KB) by

This function provides an improvement over the QUIVER3 technique for visualizing 3D vector fields.

12 Downloads

Updated

View License

% QUIVER3d *True* 3D quiver plot.
%
% This function provides an improved technique for visualizing 3D
% vector fields. It relies on the efficient use of a single patch
% call and lighting effects to provide depth cueing.
%
% QUIVER3D(X,Y,Z,U,V,W) plots velocity vectors as arrows with components
% (u,v,w) at the points (x,y,z). The matrices X,Y,Z,U,V,W must all be
% the same size and contain the corresponding position and velocity
% components. QUIVER3D automatically scales the arrows to fit.
%
% QUIVER3D(X,Y,Z,U,V,W,COLOR) provides an input argument for coloring
% the vecotors. The COLOR argument can be a single color ([1x3] or
% [3x1]), and indexed color ([1xN] or [Nx1]), or a true color ([3xN or
% Nx3). Where N is equal to the number of elements in X or Y or Z or...
%
% QUIVER3D(X,Y,Z,U,V,W,COLOR,S) automatically
% scales the arrows to fit and then stretches them by S.
% Use S=0 to plot the arrows without the automatic scaling. S=1
% provides simple autoscaling.
%
% QUIVER3D(X,Y,Z,U,V,W,COLOR,S,N) provides an input that defines the
% density of the tessellation used in generating the arrows. If N is
% high (>15) then the rendering time can be long and interactivity of
% the rendering can be slow. If N<15 the rendering is generally quick
% for ~100s of vectors. The default is N=15;
%
% H = QUIVER3D(...) returns a patch object of the arrow cluster.
%
% Example:
% quiver3d; % Generates a sample output of the function.
%
% DBE 10/17/04

Comments and Ratings (14)

Thanks for the function!
I get a constant error: 'Error: File: quiver3d.m Line: 36 Column: 1 Function definitions are not permitted in this context'.
Any help on this? Thanks!

I have a 119*255 cell array that contains land and sea area, I set the earth values to NaN and try to use quiver for plot velocity arrow but the result does not look good, because there is a dot on every land point and the arrows are not detectable.
I tried to prepare a matrix of x y u and v and then use quiver the result comes better but not good yet, because sometimes there are 2 arrow from 1 point.
look at this: https://sites.google.com/site/physic4ocean/Home/om2.png?attredirects=0&d=1

would someone help me to prepare a good look of current in this large area?

is it possible to send me a file please?

I am using R2010a and my original file is a nc file.

thank you
Dandelion
apt.man@gmail.com

Ben

Ben (view profile)

It only plots 2 arrows when I give it a command to plot 3 arrows (coordinate frame unit vectors)??? I can't seem to figure out why this is happening.

quiver3d([0,0,0],[0,0,0],[0,0,0],[1 0 0],[0 1 0],[0 0 1])

Works Great...

Best wishes

Thanks,

Divahar Jayaraman

avi tzur

R Heavy

Weird, happened again. The characters after the ampersand should be "amp" without the quotes.

R Heavy

Something got cut off in the last message:

The cursor was placed at the end of:
...==1 &

R Heavy

Couldn't even run the demo mode. Error message reads:

??? Error: File: quiver3d.m Line: 77 Column: 43
Incomplete or misformed expression or statement.

Cursor placed at the end of:
indexed_color=(size(arrow_color,1)==1 &

"amp" does not show up previous to this point.

Andrew Moss

I got an error every time I tried to run this function. Here are some samples I tried. I really didn't have time to go through your code much so I have no idea what it might be, I may even just be using it wrong but I thought I would let you know anyway

>> quiver3d
??? In an assignment A(:,matrix) = B, the number of elements in the subscript of A and the number
of columns in B must be the same.

Error in ==> F:\MATLAB Files\quiver3d.m
On line 115 ==> Evct(:,2)=cross(Evct(:,1),[1 0 0])/norm(cross(Evct(:,1),[1 0 0]));

>> quiver3d(1,1,1,0,0,1)
??? In an assignment A(:,matrix) = B, the number of elements in the subscript of A and the number
of columns in B must be the same.

Error in ==> F:\MATLAB Files\quiver3d.m
On line 115 ==> Evct(:,2)=cross(Evct(:,1),[1 0 0])/norm(cross(Evct(:,1),[1 0 0]));

Daniel Ennis

I welcom constructive feedback. I am happy to make changes to the function. If you can provide more details I can likely fix the problem, but the example you provide works as expected on my platform.

Paulo J. Paupitz Goncalves

have you tried something really simple as:
quiver3d(0,0,0,1,0,0)

I got and error.

Regards

urs Schwarz (us)

very nice work, Daniel!

Daniel Ennis

The rot3d function call should have been commented out. The two lines the precede it were intended to replace it. Another minor modification was also submitted that changes the way the arrow body diameter is scaled.

Valeri Karlov

function rot3d is missing when run quiver3d example

MATLAB Release
MATLAB 7 (R14)

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

» Watch video