Search code examples
matlab3dplot

How to create 3D-Plot in MatLab?


Please help me to create 3D-Plot in MatLab with this parameters:

x=t
y=t
z=2t^2
0<t<1

thank you!


Solution

  • Matlab plots data, not functions. So, you need to generate data that represents your function. Here I generate a vector containing 100 values of t from 0 to 1 (you could use linspace() for this if you prefer), then use it to generate the x, y, and z values:

    t = [0 : 0.01 : 1]';
    x = t;
    y = t;
    z = 2 * t.^2;
    
    plot3(x,y,z, 'r-');
    

    The plot3() call generates the plot as a red line connecting your x, y, z data points.