Three-Dimensional Plots
Three-dimensional plots basically display a surface defined by a function in two variables, g = f (x,y).
As before, to define g, we first create a set of (x,y) points over the domain of the function using the meshgrid command. Next, we assign the function itself. Finally, we use the surf command to create a surface plot.
The following example demonstrates the concept:
Use the peaks
function to define X
, Y
, and Z
as 25-by-25 matrices. Then, create a surface plot.
[X,Y,Z] = peaks(25); figure surf(X,Y,Z);
surf
creates the surface plot from corresponding values in X
, Y
, and Z
. If you do not define the color data C
, then surf
uses Z
to determine the color, so color is proportional to surface height.
No comments:
Post a Comment