How Can I Convert a 2D Plot to a 3D Plot in MATLAB?

  • Context: MATLAB 
  • Thread starter Thread starter adnan jahan
  • Start date Start date
  • Tags Tags
    3d Matlab Plot
Click For Summary

Discussion Overview

The discussion revolves around converting 2D plots to 3D plots in MATLAB. Participants are exploring methods to achieve this transformation, focusing on specific equations and the use of MATLAB functions.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant seeks guidance on converting a specific 2D plot defined by the equation s=x^2+y^3 into a 3D plot with a z-axis ranging from -1 to 1.
  • Another participant suggests using the plot3 function and setting the z component to a desired value.
  • A different participant describes their attempt to plot a parabolic equation in 3D using plot3, but encounters an error related to matrix dimensions when trying to define z as a vector.
  • The same participant notes that while the suggested method worked for a different example, they still require assistance to achieve a specific graph format as shown in an attachment.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the best approach to convert 2D plots to 3D, and there are multiple competing views and unresolved issues regarding the implementation in MATLAB.

Contextual Notes

Participants express uncertainty regarding the correct dimensions and definitions needed for the z-axis in their plots, indicating potential limitations in their current understanding of MATLAB's plotting functions.

adnan jahan
Messages
93
Reaction score
0
Dear Friends

I have made 2D plot in MATLAB and want to convert it in 3D can you give me any suggestions please.

if
s=x^2+y^3
x=linspace(0,2);
plot(y,s,'b')
this gives the plot of 2D
I want to make it in 3D for any value of z axis(-1 to 1)
what changes i have to do ?
 
Physics news on Phys.org
plot3 is the function you want, set the z component equal to the value you want.
 
not formed ,,,hmmmm
the case is,,, I have equation of two variables,,
simply
x=linspace(0,1)
y=x^2
plot(x,y,'b')
now I want to convert this parabolic in 3D
x=linspace(0,1)
z=-1:0.1:1;
y=x^2
plot3(x,y,z)
but not working it gives
? Error using ==> mpower
Matrix must be square.
 
I tried what you said for different example work but I need graph as in attachment,
 

Attachments

Last edited:

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K