Math 5-385
Info about using Matlab for plotting surfaces in 3-space
     with emphasis on parametric surfaces

Major update completed: December 12, 2008
Smaller updates done on December 15, 2008

Contents

The basics
        In this section, we'll tell you how to get started, and point you toward the basic Matlab help page that explains how to do surface plots. After reading that, you probably can go directly to material on the improved approach to surface plotting. The section on useful matrix commands still includes valuable material, but it is not possible to do surface plots without understanding that material. And when you have a basic figure that you'd like to tweak, you may consul the section on manipulating the Matlab graphics window.

Some useful matrix commands
      

An improved approach to surface plotting    (under construction as of December 10, 2008)
 
   As usual, the goal is to draw a surface which is given parametrically:

x = f(t,u)
y = g(t,u)
z = h(t,u),
where the variables range through some specific intervals, say  a ≤ t ≤ b,    c ≤ u ≤ d.
As a specific instance, let's consider the Whitney umbrella surface (see exercise 9 in sec 3.3).
Thus,  f(t,u) = t,   g(t,u) = ,   and   h(t,u) = tu,   so that: x = t
y = u²
z = tu,
where  -1 ≤ t ≤ 1  and  -1 ≤ u ≤ 1.

Manipulating the Matlab graphics window

We'll look at the previous surface, i.e. the Whitney umbrella surface, to see specific examples of things that can be done. First of all, since t occurs only to the first power in the parametrization, our surface is a ruled surface. This means that it is a union of straight lines. To show this more clearly, we will change the grid so that the u-interval has divisions only at -1, 0, and 1. And (skipping a step that was done in class), we'll also combine this with dividing the t interval into 20 subintervals instead of 10. We keep the functions  f, g, h  and the vectorized functions  F, G, H  as before, and just re-calculate the steps that need to be changed: r = [-1 0 1];
s = -1:0.05:1;
[t,u] = meshgrid(r,s);
X = eval(F);
Y = eval(G);
Z = eval(H);
S = surf(X,Y,Z);
This time we get the following figure:
 
        
 
This has some desirable features, but the color of the right half is disappointing. This is related to the default values that Matlab uses in calculating the color data. We can, however, use Matlab's set to substitute a matrix of our own choice for the color data. This matrix must be of the same size as the X, Y or Z matrices in the plot. For our ruled surface, the u matrix is a good choice, because the lines on the surface correspond to u-values. Accordingly, here is an appropriate command: set(S,'CData',u) Here is the result:
 
        
 
Now, it might be nice to see the surface from a different direction. To accomplish that, we click on the rotate icon    on the toolbar and then use the mouse to rotate the figure. Among many other possibilities, here is one position to which it can be moved:
 
        
 

Here are some other things that you can do:

Further specific examples and sugestions
       Although the first two examples below are given by trigonometric parametrizations, they're actually algebraic surfaces -- the first one obviously so, because of its well known equation  x2 + y2 + z2 = 1.
Any of the matlab text presented below can be copied from this window and pasted into a Matlab command window. If desired, you can then modify it to plot other figures.

For more information. On the Matlab help page (type   helpdesk   at the Matlab prompt)
see the following items under the MATLAB topics menu:
 


Comments and questions to:  roberts@math.umn.edu


Back to   the help page index.

Back to  the Math 5385 class homepage.