www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ThreeDPlotsGSExample.m

    %% 3-D Plots
% Three-dimensional plots typically display a surface defined by a function
% in two variables, _z = f(x,y)_ .
%%
% To evaluate _z_, first create a set of (_x,y_) points over the domain
% of the function using |meshgrid|.

% Copyright 2015 The MathWorks, Inc.

[X,Y] = meshgrid(-2:.2:2);                                
Z = X .* exp(-X.^2 - Y.^2);
%%
% Then, create a surface plot.
surf(X,Y,Z)
%%
% Both the |surf| function and its companion |mesh| display surfaces in
% three dimensions. |surf| displays both the connecting lines and the faces
% of the surface in color. |mesh| produces wireframe surfaces that color
% only the lines connecting the defining points.