资源描述
MATLAB 画三维函数图下面将这几天所做的图像及程序小记一下(望大虾指教)一、螺旋线1. 静态螺旋线a=0:0.1:20*pi;h=plot3(a.*cos(a),a.*sin(a),2.*a,b,linewidth,2);axis(-50,50,-50,50,0,150);grid onset(h,erasemode,none,markersize,22);xlabel(x 轴);ylabel(y 轴);zlabel(z 轴); title(静态螺旋线);2. 动态螺旋线t=0:0.1:10*pi;i=1;h=plot3(sin(t(i),cos(t(i),t(i),*,erasemode,none);grid onaxis(-2 2 -2 2 0 35)for i=2:length(t)set(h,xdata,sin(t(i),ydata,cos(t(i),zdata,t(i);drawnowpause(0.01)endtitle( 动态螺旋线 );( 图略 )3. 圆柱螺旋线t=0:0.1:10*pi;x=r.*cos(t);y=r.*sin(t);z=t;plot3(x,y,z,h,linewidth,2);grid onaxis(square)xlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title( 圆柱螺旋线 )二、旋转抛物面b=0:0.2:2*pi;X,Y=meshgrid(-6:0.1:6);Z=(X.A2+Y.A2)./4;meshc(X,Y,Z);axis(square)xlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title(旋转抛物面)或直接用:ezsurfc(X.A2+Y.A2)./4)三、椭圆柱面load clownezsurf(2*cos(u),4*sin(u),v,0,2*pi,0,2*pi)view(-105,40)% 视角处理%添加坐标轴说明shading interp % colormap(map) grid onaxis equalxlabel(x 轴);ylabel(y title(椭圆柱面)灯光处理%颜色处理%添加网格线%使x,y轴比例一致轴);zlabel(z 轴);%添加标题四、椭圆抛物面b=0:0.2:2*pi;X,Y=meshgrid(-6:0.1:6);Z=X.A2./9+Y.A2./4;meshc(X,Y,Z);axis(square)xlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title(椭圆抛物面)或直接用:ezsurfc(X.A2./9+Y.A2./4)m t抢步阮五、双叶双曲面ezsurf(8*tan(u)*cos(v),8.*tan(u)*sin(v),2*sec(u),-pi./2,3*pi./2,0,2*pi)axis equalgrid onaxis squarexlabel(x轴);ylabel(y轴);zlabel(z 轴);title(双叶双曲面)如l- h六、双曲柱面load clown ezsurf(2*sec(u),2*tan(u),v,-pi/2,pi/2,-3*pi,3*pi)hold on%在原来的图上继续作图ezsurf(2*sec(u),2*tan(u),v,pi/2,3*pi/2,-3*pi,3*pi) colormap(map)shading interpview(-15,30)axis equalgrid onaxis equalxlabel(x轴);ylabel(y轴);zlabel(z 轴);title(双曲柱面): 1s5F七、双曲抛物面(马鞍面)X,Y=meshgrid(-7:0.1:7);Z=X.A2./8-Y.A2./6;meshc(X,Y,Z);view(85,20)axis(square)xlabel(x轴);ylabel(y轴);zlabel(z 轴);title(双曲抛物面)或直接用:ezsurfc(X.A2./8-Y.A2./6)八、抛物柱面X,Y=meshgrid(-7:0.1:7);Z=Y.A2./8;h=mesh(Z);rotate(h,1 0 1,180)% 旋转处理%axis(-8,8,-8,8,-2,6);axis(square)xlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title(抛物柱面)或直接用:ezsurfc(Y.A2./8)eo的眼 do.l0 叭妝極15a九、环面ezmesh(5+2*cos(u)*cos(v),(5+2*cos(u)*sin(v),2*sin(u), 0,2*pi,0,2*pi) axis equalgrid onxlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title(环面)Id十、椭球ezsurfc(5*cos(u)*sin(v) ,(3*sin(u)*sin(v),4*cos(v),0,2*pi,0,2*pi)axis equalgrid onxlabel(x 轴);ylabel(y 轴);zlabel(z轴);title(椭球)十一、单叶双曲面ezsurf(4*sec(u)*cos(v),2*sec(u)*sin(v),3.*tan(u),-pi./2,pi./2,0,2*pi)axis equalgrid onxlabel(x 轴);ylabel(y 轴);zlabel(z轴);title(单叶双曲面)十二、旋转单叶双曲面load clownezsurf(8*sec(u)*cos(v),8.*sec(u)*sin(v),2*tan(u),-pi./2,pi./2,0,2*pi) colormap(map)view(-175,30)%alpha(.2)%透明处理axis equalgrid onaxis squarexlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title(旋转单叶双曲面)找性c, :O十三、圆柱面subplot(1,2,1)ezsurf(2*cos(u),2*sin(u),v,0,2*pi,0,2*pi)grid onshading interpaxis equalxlabel(x 轴);ylabel(y 轴);zlabel(z 轴);title(圆柱面)subplot(1,2,2)cylinder(30)shading interpaxis squaretitle(调用cylinder函数所得圆柱面)Y槁xM下面给出用colormap() 改变图像颜色的例子:(用了灯光效果shading interp)colormap();%hot/cool/copper/gray/hsv/spring/summer/winter.colormap(hsv)HWHHpPlcolormap(gray)-4:colormap(cool)colormap(copper)下面做了旋转(view( ) 、灯光(“ shading interp )、透明(“ alpha()处理:X*1*
展开阅读全文