- #1

- 590

- 0

can someone please help me plot 3d graphs on MATLAB, for example

z=x

^{2}+2x+y

^{2}-y

how can i input x,y,z so that MATLAB will give me the surface graph of this function

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

In summary, to plot a 3D graph in MATLAB, you can use the "plot3" function and adjust the graph using other functions like "xlabel", "title", and "view". You can also plot multiple 3D graphs on the same figure by using the "hold on" command and creating subplots with the "subplot" function. To change the color or style of your graph, you can specify properties in the "plot3" function or use the "ColorOrder" property for multiple plots. Adding a legend is possible with the "legend" function and the "saveas" function can be used to save the graph as an image file with customizable properties.

- #1

- 590

- 0

can someone please help me plot 3d graphs on MATLAB, for example

z=x

how can i input x,y,z so that MATLAB will give me the surface graph of this function

Physics news on Phys.org

- #2

Homework Helper

Gold Member

- 2,147

- 50

To plot a 3D graph in MATLAB, you can use the "plot3" function. This function takes in three vectors representing the x, y, and z coordinates of your data points and plots them in 3D space. You can also add labels, titles, and adjust the viewing angle of the graph using other functions like "xlabel", "title", and "view".

Yes, you can plot multiple 3D graphs on the same figure using the "hold on" command. This allows you to add new plots to an existing figure without erasing the previous ones. You can also use the "subplot" function to create a grid of subplots on a single figure.

You can change the color or style of your 3D graph by specifying the "Color" and "LineStyle" properties in the "plot3" function. For example, you can use "plot3(x,y,z,'r--')" to plot a red dashed line. You can also use the "ColorOrder" property to change the default colors used for multiple plots.

Yes, you can add a legend to a 3D graph in MATLAB by using the "legend" function. This function takes in a cell array of strings representing the labels for each plot, and it will automatically add a legend to your graph. You can also specify the location and other properties of the legend using additional arguments.

To save your 3D graph as an image file in MATLAB, you can use the "saveas" function. This function takes in the handle of your figure and the desired file format (e.g. 'png', 'jpg') as arguments. You can also adjust the resolution and other properties of the image using additional arguments.

Share:

- Replies
- 3

- Views
- 197

- Replies
- 10

- Views
- 877

- Replies
- 5

- Views
- 734

- Replies
- 4

- Views
- 978

- Replies
- 1

- Views
- 559

- Replies
- 3

- Views
- 954

- Replies
- 4

- Views
- 882

- Replies
- 4

- Views
- 1K

- Replies
- 6

- Views
- 863

- Replies
- 14

- Views
- 3K