在matlab中绘制完子图以后,再一次绘制图形会显示在之前绘制的子图最后,会影响结果的显示
问题出现代码:
t = 0:0.1:2*pi;
[X,Y,Z] = cylinder(sin(t) + cos(t)); %创建圆柱 sin(t) + cos(t)为沿圆柱单位高度的等距高度的半径
subplot(2,2,1); mesh(X); title('X');
subplot(2,2,2); mesh(Y); title('Y');
subplot(2,2,3); mesh(Z); title('Z');
subplot(2,2,4); mesh(X,Y,Z); title('X,Y,Z');

[x,y,z] = sphere;
r = 2;
surf(x*r, y*r, z*r)
axis equal

解决方法: 在新绘制图形代码前加 clf
clf % 把figure里面的数据全部清除
[x,y,z] = sphere;
r = 2;
surf(x*r, y*r, z*r)
axis equal

4710





