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

3D plot help

  1. Jul 23, 2010 #1
    I have 2 variables and data points corresponding to them and so would like to plot this (I think using the plot3 function for a 3D graph) but I'm having trouble writing my code.

    Each variable ranges from 0 to 1 (in 0.1 intervals) and so this would be the x and z axis, and I have data points corresponding to each variable point in 11 by 11 matrix (which would be plotted on the y axis).

    Since the data all has to be in matrices (or vectors) of the same size, I made my x and z values into matrices, and used this function:

    plot3(z,y,x,'DisplayName','z,y,x');figure(gcf)

    but the figure doesn't look right and I'm not sure what I'm doing wrong.

    Please help!
     
  2. jcsd
  3. Jul 26, 2010 #2
    Since you already have an 11x11 matrix of your z values you might try

    ListPlot3D[Table[Sin[x]Cos[y], {x, 0, 2Pi, 2Pi/11}, {y, 0, 2Pi, 2Pi/11}]]

    Compare that with

    Plot3D[Sin[x]Cos[y], {x, 0, 2Pi}, {y, 0, 2Pi}]

    and then try your own y data

    ListPlot3D[y]

    If you have version 7 and you can get your data in a form

    tbl={{x1,y1,z1},{x2,y2,z2}...{x11,y11,z11}}

    then you can try

    ListPlot3D[tbl]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook