Whether it's for research, a school assignment, or a work presentation, 3-D plots are great for visualizing what a complicated set of data looks like. With the help of MATLAB (Matrix Laboratory), you'll be able to create stunning 3-D visuals with the data you provide. Using MATLAB for this purpose allows you to have complete control over the customization of your graph. From colors to shading and lighting, the only tools needed are MATLAB and your know-how.

Part 1
Part 1 of 3:

Constructing the Domain

  1. In the default layout this should appear automatically as the biggest window displayed.
  2. Afterwards, select layout and then "Default".
    Advertisement
    • This is typically done in the form of x=[vector or function] and y=[vector or function]
    • Remember to use the dot operator when multiplying or dividing vectors and matrices. Otherwise errors will occur.
    Advertisement
Part 2
Part 2 of 3:

Producing the Grid in the xy-Plane

  1. In order to accomplish this, two commands must be used.
    • The first is the mesh function. By using this, the result will be a wireframe mesh graph.
    • The other is the surf function. When using surf, the result will be a 3-D surface plot.
    • The command will be formatted as follows: [xx,yy]=meshgrid(x,y) .
    • In the workspace window you will see that the variables xx and yy have been defined.
    Advertisement
Part 3
Part 3 of 3:

Defining "zz" and Plotting the Surface

    • Use the relationship you know exists between x and y. This is likely to be a function or formula.
    • e.g., zz=xx.^2-yy.^2
    • From the z components in the matrix "zz", the surf command will create a 3-D shaded surface.
    • This is the point in which you will relate xx , yy , and zz together.
    • The actual command line will be in the format of surf(xx,yy,zz) .
  1. There is a toolbar at the top of the window where the new plot has appeared. This toolbar contains many options and features that can be used to manipulate your 3-D plot.
  2. This is done by using the command line shading interp .
    Advertisement

Expert Q&A

Ask a Question

      Advertisement

      Tips

      • If you receive an error that says, "Undefined function or variable __", check your workspace for that variable.
        • If it doesn't exist, be sure to create/define it before continuing.
      • If you receive an error that says, "Unexpected MATLAB expression", check to see if what you typed is a valid expression and all built-in functions are spelled correctly.
      Advertisement

      Things You'll Need

      • A set of data that you wish to plot
      • A computer running MATLAB 2012 (or later)


      About this article

      Thanks to all authors for creating a page that has been read 26,338 times.

      Is this article up to date?

      Advertisement