File Exchange

image thumbnail

3D/2D vector field plotter

version 1.0 (1.75 KB) by

This function can plot both 3D and 2D vector field based on the input symbolic expression ...

4.31579
19 Ratings

15 Downloads

Updated

No License

vectline is "vector field line plotter". Depending on the dimension of coordinate axis, vectline can plot both 3D and 2D vector field line.

Example for 2D field
>> syms x y
>> F = [-y, x];
>> vectline(F,[x,y],[-1,1,-1,1])

Example for 3D field

>> syms x y z
>> F = [x*y^2, x*y, z];
>> vectline(F,[x,y,z],[-1,1,-2,3,1,3])

Comments and Ratings (21)

George

George (view profile)

George

George (view profile)

@ Paul T, how to add the density option

Hi, i found an easy way to modify vectline to add the "density option" as shown in the youtube vid of RobertThalbertPhD.
Open the vectline.m and save as e.g. "vectline_a.m",then add another input variable "a" to the 1. line of the m.file to obtain
"function vectline(f,crdaxis,crdrange,a)". Then replace the "5" with an "a" in the lines 27,28,29 and 55,56 to obtain
"dx=(xmax-xmin)/a;
dy=(ymax-ymin)/a;
dz=(zmax-zmin)/a;"
and
"dx=(xmax-xmin)/a;
dy=(ymax-ymin)/a;"
respectively.
Now the number of vectors in 2D will be a^2 and in 3D a^3.
Note that now you have to pass a number that will specify how many vectors are plottet in each direction, else you will receive an error.

Great so far, but I have one question: I am trying to do this for the vector field F=[0.5*x,0*y] and it's giving me an error message. Any ideas why?

David Reilly

Simple and Elegant.

Max

Max (view profile)

Exactly what I needed. Is there a way to make the values of the axes in increments of 1 instead of 2?

Alexandr

Hello. Interesting code. I need this kind of graphs for my work but I cannot understand what it actually plots. Could you please tell me more about those arrows. What do they show and which values of a function are involved in the plotting? Thank you. Alex.

Jose Ortiz

Very nice!!!!

Aamir

Aamir (view profile)

I need exactly such a plotting tool but for numeric arrays not symbolic maths. Any suggestions please?

Arun Sahu

The Function is really useful, but would have been better if we could control the precision... to get a more accurate plot.

Paul T

Very useful function. It would be nice if it is possible to specify the density (on the plot) of the vectors. Good job.

Daniel Sutton

A very good piece of code, this should be a standard feature of MATLAB

cricket4me Usulub

how the heck do i open this??

Will Ludington

using MATLAB R2006b intel-based mac version, the original source code does not plot. adding a line to the code to produce a new figure before the quiver command fixes the problem.
......

u=junk(:,1:k/3,:);
v=junk(:,k/3+1:2*k/3,:);
w=junk(:,2*k/3+1:k,:);

figure; %<<ADD THIS LINE>>

quiver3(px,py,pz,u,v,w)

Quentin Brandon

Works perfectly.
Compact and clean code easily tweakable.

camilo calvo

PAJ PANB

Krastimir Popov

Mike Weems

Awesome......just what i needed. Thanks

Vince SaBella

Peter Bodin

Really nice function. It would be even nicer if it returned the quivergroup handles, but I could easily fix that myself.

MATLAB Release
MATLAB 6.5 (R13)

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

» Watch video