Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica, gradient plot on the graph

  1. Aug 1, 2012 #1
    Hi,
    I need to plot a vector field 2x,2y,0 which is the gradient of the function x^2+y^2. I need to plot it only in some interesting points (points on the paraboloid x^2+y^2). So I tried something like

    a=Table[{{x,y,x^2+y^2},{2x,2y,0}},{x,-2,2,0.5},{y,-2,2,0.5}]
    ListVectorPlot3D[a]

    It did not work. The definition of ListVectorPlot3D[{{x,y,z},{a,b,c}},...] says that it generates a 3D vector plot from vector field values {a,b,c} given at specified points {x,y,z}.

    Any idea how I might plot that gradient on the paraboloid ? It would be really unpleasant if I had to do every single vector with Graphics3D[]

    thanks
     
  2. jcsd
  3. Aug 2, 2012 #2

    Hepth

    User Avatar
    Gold Member

    Code (Text):

    pnts = Flatten[Table[{x, y, x^2 + y^2}, {x, -2, 2, 1/4}, {y, -2, 2, 1/4}], 1];

    plv = VectorPlot3D[{2 x , 2 y, 0}, {x, -2, 2}, {y, -2, 2}, {z, 0, 8},  VectorPoints -> pnts, VectorColorFunction -> "ThermometerColors",    VectorScale -> Small];

    plp = Plot3D[x^2 + y^2, {x, -2, 2}, {y, -2, 2},  ColorFunction -> "GrayTones", BoxRatios -> {3, 3, 2}];

    Show[plp, plv, ImageSize -> 600]
     
    Gives me this: It took me a bit of time, but I have always wanted to learn how to do this anyway so 30 minutes well spent.

    Does anyone know how i can make the arrows START at the point rather than be centered at it?
     

    Attached Files:

    Last edited: Aug 2, 2012
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica, gradient plot on the graph
  1. Mathematica plot (Replies: 1)

  2. Plot in mathematica (Replies: 2)

Loading...