Trouble Plotting 3D Graph with Two Variables and Matrix Data

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
jemma
Messages
35
Reaction score
0
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!
 
Physics news on Phys.org
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]