调用的函数
- subplot()函数
这个函数决定图的布局以及在那里开始画;
例如subplot(2,2,3)表示将画板分为2x2的4块,在其中的第三块开始画,显示结果如图

subplot(1,3,2)

绘图函数
- mesh()用于绘制坐标网格图;调用格式:mesh(x,y,z,c)(补充:meshc--带等高线的三位网格曲面函数;meshz--带底座的三维网格曲面函数)
- surf()用于绘制三维曲面图;调用格式:surf(x,y,z,c)
- sphere()用于绘制标准三维曲面图
- cylinder();调用格式:cylinder(R,n)
其中R是一个向量,存放等间隔高度上的半径,n表示圆周上有n个间隔点
一般情况下,x,y,z是维数相同的矩阵,x,y是网格坐标矩阵,z是网格点上的高度矩阵,c用于指定在不同高度下的颜色范围
例1
在xy平面内选择区域[-8,8]X[-8,8]绘制函数

[x,y]=meshgrid(-8:0.5:0.8);
z=sin(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2+eps);#eps是一个极小的数,这里是为了防止分母为零
subplot(2,2,1);
mesh(x,y,z);

subplot(2,2,2);
meshc(x,y,z);

subplot(2,2,3)
meshz(x,y,z)
subplot(2,2,4);
surf(x,y,z);

例2
t=0:pi/20:2*pi;
[x,y,z]= cylinder(2+sin(t),30);
surf(x,y,z);

网友评论