[x,y,z]=sphere;
subplot(121)
mesh(x,y,z)
hidden on;
subplot(122)
mesh(x,y,z)
hidden off; %网格图像透明与否
[x,y,z]=peaks/sphere
x=linspace(-2,2,40);
y=linspace(-2,2,40);
[X,Y]=meshgrid(x,y);
Z=X.*exp(-(X.^2+Y.^2));
subplot(121)
surf(X,Y,Z)
subplot(122)
surf(X,Y,Z)
shading flat; %shading interp %曲面图是否有网格线,平滑处理
x=linspace(-2,2,40);
y=linspace(-2,2,40);
[X,Y]=meshgrid(x,y);
i=find(x>0.5&x<0.7);
j=find(y>0.4&y<0.6);
Z=X.*exp(-(X.^2+Y.^2));
Z(i,j)=nan*Z(i,j);
surf(X,Y,Z) %将find函数指定部位挖掉,其中nan可以换成其他的数值例如0、1
[x,y,z]=peaks(30);
contour3(X,Y,Z,16) %draw sixteen contour lines, specify the number of line and line’s color
函数 contour3 的二维图就等价于contour。
[X,Y,Z]=peaks(30);
contour(X,Y,Z,16) %draw sixteen contour lines, specify the number of line and line’s color
surf的二维等效函数是pcolor,它代表伪彩色。
[X,Y,Z]=peaks(30);
subplot(121)
pcolor(X,Y,Z);
subplot(122)
contour(X,Y,Z,20) %mesh和surf的二维图形的比较。
[X,Y,Z]=peaks(30);
pcolor(X,Y,Z);
shading interp
hold on
contour(X,Y,Z