Trouble Plotting 3D Graph with Two Variables and Matrix Data

Click For Summary
SUMMARY

The discussion focuses on plotting a 3D graph using the plot3 function in MATLAB, specifically for two variables ranging from 0 to 1 in 0.1 intervals. The user is attempting to visualize data points organized in an 11x11 matrix, with x and z values represented as matrices. The suggested solutions include using ListPlot3D with a sine-cosine function and formatting the data into a table for better visualization. Key functions mentioned are ListPlot3D and Plot3D, which are essential for achieving the desired 3D plots.

PREREQUISITES
  • Familiarity with MATLAB programming language
  • Understanding of 3D plotting functions in MATLAB, specifically plot3, ListPlot3D, and Plot3D
  • Knowledge of matrix manipulation in MATLAB
  • Basic understanding of trigonometric functions and their graphical representations
NEXT STEPS
  • Learn how to format data into tables in MATLAB for 3D plotting
  • Explore advanced features of ListPlot3D for enhanced visualization
  • Study the differences between ListPlot3D and Plot3D in MATLAB
  • Investigate the use of trigonometric functions in 3D plots for data representation
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and researchers who need to visualize complex data sets in three dimensions, particularly those working with matrix data and trigonometric functions.

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 ·
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
8K
Replies
6
Views
2K