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

Graphing 3d in MATLAB

  1. Apr 23, 2009 #1
    i am learning MATLAB, but have not yet learned anything do do with graphing, but need a program that can plot x.y.z graphs for my calculus work,

    can someone please help me plot 3d graphs on MATLAB, for example

    z=x2+2x+y2-y

    how can i input x,y,z so that MATLAB will give me the surface graph of this function
     
  2. jcsd
  3. Apr 23, 2009 #2
    Modify as you need:

    [X Y] = meshgrid(linspace(-10,10));
    z=X.^2+2.*X+Y.^2-Y;
    mesh(X,Y,z)

    Alternatively use "surf" instead of "mesh".
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook