
上QQ阅读APP看书,第一时间看更新
1.7 三维网图的高级处理
1.消隐处理
例1-18 比较网图消隐前后的图形

图1-19所示为消隐前的网图,图1-20所示为消隐后的网图.

图 1-20
2.裁剪处理
利用不定数NaN的特点,可以对网图进行裁剪处理.
例1-19 图形裁剪处理

图1-21所示为裁剪前的网图,图1-22所示为裁剪后的网图.

图 1-21

图 1-22
注意:裁剪时矩阵的大小一定要相同.
3.三维旋转体的绘制
为了一些专业用户可以更方便地绘制出三维旋转体,MATLAB专门提供了两个函数:柱面函数cylinder和球面函数sphere
(1)柱面图
由函数cylinder实现柱面图的绘制.
[X,Y,Z]=cylinder(R,N)此函数以母线向量R生成单位柱面.母线向量R是在单位高度里等分刻度上定义的半径向量.N为旋转圆周上的分格线的条数.可以用surf(X,Y,Z)来表示此柱面.
[X,Y,Z]=cylinder(R)或[X,Y,Z]=cylinder此形式为默认N=20且R=[11]
例1-20 柱面函数演示举例

绘制结果如图1-23所示.

图 1-23
例1-21 旋转柱面图.

(2)球面图
由函数sphere来实现球面图的绘制.
[X,Y,Z]=sphere(N) 此函数生成3个(N+1)∗(N+1)的矩阵,利用函数surf(X,Y,Z)可产生单位球面.
[X,Y,Z]=sphere 此形式使用了默认值N=20.
Sphere(N) 只是绘制了球面图而不返回任何值.
例1-22 绘制地球表面的气温分布示意图.
