Matlab 大一上测试前的画图练习
1 p38 示例22
x=0:pi/100:2*pi; y1=2*exp(-0.5*x).*sin(2*pi*x); y2=2*exp(-0.5*x); y3=-2*exp(-0.5*x); plot(x,y1,'m-',x,y2,'m--',x,y3,'m--'); axis([0,2*pi,-2,2]); grid on; xlabel('x轴'); ylabel('y轴'); title('函数曲线'); text(3,0.5,'\leftarrow y2=2*exp(-0.5*x)');
2,p39 示例23
t=0:pi/20:2*pi; [x,y,z]=cylinder(2+sin(t),100); surf(x,y,z); grid off; axis off; shading interp; colormap(hot); light('Posi',[2 -1 0]); light('Posi',[-4,-1,0]); %设置光源 lighting phong; material metal; %设置面的反射属性
3,z=x^2+y^2
x=-2:0.1:2; y=x; [xb,yb]=meshgrid(x,y); zb=xb.^2+yb.^2; surf(xb,yb,zb);
4,消去z轴上大于4的点
x=-2:0.1:2; y=x; [xb,yb]=meshgrid(x,y); zb=xb.^2+yb.^2; zb(find(xb.^2+yb.^2>4))=NaN; surf(xb,yb,zb);
matlab 可用NaN(区分大小写)对图像进行镂空处理