Trouble Plotting 3D Graph with Two Variables and Matrix Data

AI Thread Summary
The discussion focuses on plotting a 3D graph using two variables and corresponding matrix data points. The user is attempting to use the plot3 function but is encountering issues with the output not appearing correctly. They have created matrices for their x and z values, with an 11 by 11 matrix for the y-axis data. Suggestions include using ListPlot3D with a sine-cosine function as a comparison and formatting the data into a specific table structure for better plotting results. The conversation emphasizes the importance of ensuring data matrices are correctly aligned for successful visualization.
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]
 

Similar threads

Replies
3
Views
2K
Replies
4
Views
2K
Replies
5
Views
2K
Replies
5
Views
2K
Replies
2
Views
3K
Replies
2
Views
2K
Replies
3
Views
7K
Replies
1
Views
2K
Back
Top