MATLAB Learn How to Graph 3D in MATLAB

Click For Summary
To plot 3D graphs in MATLAB for calculus work, you can use the following code snippet to create a surface graph of the function z = x^2 + 2x + y^2 - y. First, generate a grid of x and y values using the meshgrid function. Then, calculate the corresponding z values based on the function. The code provided is:[X, Y] = meshgrid(linspace(-10, 10)); z = X.^2 + 2.*X + Y.^2 - Y; mesh(X, Y, z)For a different visual representation, you can replace "mesh" with "surf" to create a surface plot. This approach effectively allows for the visualization of 3D surfaces in MATLAB.
Dell
Messages
555
Reaction score
0
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
 
Physics news on Phys.org
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".
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K