视频
拓展学习
例1 绘制函数=(−1)^2+(−2)^2−1曲面,并从不同视点展示曲面。
[x,y]=meshgrid(0:0.1:2, 1:0.1:3);
z=(x-1).^2+(y-2).^2-1;
subplot(2,2,1); mesh(x,y,z)
title('方位角=-37.5{\circ},仰角=30{\circ}')
subplot(2,2,2); mesh(x,y,z)
view(0,90);title('方位角=0{\circ},仰角=90{\circ}')
subplot(2,2,3); mesh(x,y,z)
view(90,0); title('方位角=90{\circ},仰角=0{\circ}')
subplot(2,2,4); mesh(x,y,z)
view(-45,-60); title('方位角=-45{\circ},仰角=-60{\circ}')
例2 创建一个灰色系列色图矩阵。
c = [0, 0.2, 0.4, 0.6, 0.8, 1.0]';
cmap = [c, c, c];
surf(peaks)
colormap(cmap)
或
cmap=gray(6);
surf(peaks)
colormap(cmap)
例3 使用同一色图,以不同着色方式绘制圆锥体。
[x,y,z]= cylinder(pi:-pi/5:0,10);
colormap(lines);
subplot(1,3,1);
surf(x,y,z); shading flat
subplot(1,3,2);
surf(x,y,z); shading interp
subplot(1,3,3);
surf(x,y,z);
例4 绘制3/4圆。
t = linspace(0,2*pi,100);
x = sin(t);
y = cos(t);
p = y > 0.5;
y(p)= NaN;
plot(x,y)
axis([-1.1,1.1,-1.1,1.1])
axis square
grid on
例5 绘制3/4球面。
[X, Y, Z] = sphere(60);
p = Z>0.5;
Z(p) = NaN;
surf(X, Y, Z)
axis([-1, 1, -1, 1, -1, 1])
axis equal
view(-45, 20)

