Plot 3d vectors

Plot real 3d arrows from .stl file. Similar to quiver
1.3K Downloads
Updated 22 Nov 2010

View License

h=vector3d(X,Y,Z,U,V,W,'Property','Value',...)

Plot 3d vectors (real 3d) from .stl file to specified location and direction.

basically same usage as quiver3. Property/value pairs are passed to patch.
Some additional property/values are available:

h=vector3d(...,'FileName',file) : string arry with name of .stl file (for example 'arrow4.stl').

h=vector3d(...,'Scale',[sx sy sz]) : scales along the x-axis by sx, along the y-axis by sy, and along the z-axis by sz. If scalar, Vectors are scaled uniformly.

h=vector3d(...,'MaxVert',nmax) : Maximum number of vertices per vector. Lower this value if many vectors have to be plotted. Default is 200.

h=vector3d(...,'Lighting','gouraud') : Sets both, edge and face lighting. Default is flat lighting
h=vector3d(...,'Color',rgb) : Sets face and edge color to specified color (indexed or true rgb). When omitted the vector length and current colormap are used.

h=vector3d(...,'ColorMap',cmap) : sets the colormap to cmap for plotting. Minimum (but non-zero) and maximum data are mapped to the interval [0 1].

h=vector3d(...,'LightDirection',[x y z]) : Adds a infinite light to the axes with specified position [x y z]

Example:

[X,Y,Z]=sphere(20);
[U,V,W] = surfnorm(X,Y,Z);
surf(X,Y,Z);
hold on
h=vector3d(X,Y,Z,U,V,W,'FileName','arrow2.stl','Scale',0.25,'Lighting',...
'gouraud','ColorMap','jet','LightDirection',[-1 -1 1])

Cite As

Pirmin Borer (2026). Plot 3d vectors (https://www.mathworks.com/matlabcentral/fileexchange/29490-plot-3d-vectors), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.0.0.0