大家好,又见面了,我是你们的朋友全栈君。
matlab画圆命令.doc
%%圆环面R=6;r=2;symsuv;ezmesh((R+r*cos(u))*cos(v),(R+r*cos(u))*sin(v),r*sin(u));axisequal;%%圆盘R=6;r=2;theta=linspace(0,2*pi,90);ph=linspace(r,R,30);[t,p]=meshgrid(theta,ph);r=t*0;[x,y,z]=pol2cart(t,p,r);mesh(x,y,z);axisequal;%%a.画椭球a=1;b=2;c=3;figure(1),title( 椭球 )ellipsoid(0,0,0,a,b,c)%shadinginterpboxon;gridoffcolormaphsv%%b.单叶双曲面[x,y]=meshgrid(-2:0.2:2,-2:0.2:2);z=sqrt(c.^2*(x.^2/(a.^2)+y.^2/(b.^2)-1));%figure(2)subplot(121),title( 单叶双曲面 )surf(x,y,real(z))holdon;surf(x,y,-real(z))%[u,v]=meshgrid(linspace(0,2*pi,50),linspace(-1*pi/2,pi/2,50));x=a.*sec(v).*cos(u);y=a.*sec(v).*sin(u);z=c.*tan(v);subplot(122),title( 单叶双曲面 )surf(x,y,z)%shadinginterpboxon;gridoffcolormaphsv%%c.双叶双曲面[x,y]=meshgrid(-2:0.2:2,-2:0.2:2);z=sqrt(c.^2*(x.^2/(a.^2)-y.^2/(b.^2)-1));%figure(3)subplot(121),title( 双叶双曲面 )surf(x,y,real(z))holdon;surf(x,y,-real(z))%[u,v]=meshgrid(linspace(0,2*pi,50),linspace(-1*pi/2,3*pi/2,50));x=a.*tan(v).*cos(u);y=a.*tan(v).*sin(u);z=c.*sec(v);subplot(122),title( 单叶双曲面 )mesh(x,y,z)%shadinginterpboxon;gridoffcolormaphsv%%d.椭圆抛物面[x,y]=meshgrid(-2:0.2:2,-2:0.2:2);z=(x.^2/(a.^2)+y.^2/(b.^2))./2;%figure(4),title( 椭圆抛物面 )surf(x,y,z)%colormapgray%%e.马鞍面[x,y]=meshgrid(-2:0.2:2,-2:0.2:2);z=(x.^2/(a.^2)-2.*y.^2/(b.^2));%figure(5),title( 马鞍面 )surf(x,y,z)%shadinginterpboxon;gridoffcolormaphsv%%f.圆环面r=2;R=4;[u,v]=meshgrid(linspace(0,2*pi,50),linspace(0,2*pi,50));x=(R+r.*cos(v)).*cos(u);y=(R-r.*cos(v)).*sin(u);z=r.*sin(v);%figure(6)subplot(131),title( 圆环面1 )surf(x,y,z)%symsuvsubplot(132),title( 圆环面2 )ezmesh( (4+2*cos(v))*cos(u) , (4-2*cos(v))*sin(u) ,. 2*sin(v) ,[0,2*pi,0,2*pi])subplot(133),title( 圆环面3 )ezsurf( (4+2*cos(v))*cos(u) , (4-2*cos(v))*sin(u) ,. 2*sin(v) ,[0,2*pi,0,2*pi])%shadinginterpboxon;gridoffcolormaphsv%%g.螺旋面u=linspace(0,2*pi);v=linspace(0,6*pi);[U,V]=meshgrid(u,v);x=(4+sin(20*U)).*cos(V);y=(4+sin(20*U)).*sin(V);z=2*V;figure(7),title( 螺旋面 )mesh(x,y,z)axisequal%%h.螺旋卷筒clearallR=2;b=2;u=linspace(0,2);v=linspace(0,6*pi);[U,V]=meshgrid(u,v);x=U.*cos(V);y=U.*sin(V);z=U.*V;figure(8),title( 螺旋卷筒 )mesh(x,y,z)axisequalaxisoff%%i.螺旋管,俗称“弹簧”u=linspace(0,2*pi,100);v=linspace(0,6*pi,100);[U,V]=meshgrid(u,v);X=(4+sin(U)).*cos(V);Y=(4+sin(U)).*sin(V);Z=cos(U)+V;figure(9),title( 螺旋管 )mesh(X,Y,Z)axisequalaxisoff%%j.圆柱上的缎带u=linspace(0,2);v=linspace(0,6*pi);[U,V]=meshgrid(u,v);X=2*cos(V);Y=2*sin(V);Z=U+V;figure(10),title( 圆柱上的缎带 )mesh(X,Y,Z)axisequalaxisoff%%k.纽带u=linspace(0,2);v=linspace(0,6*pi);[U,V]=meshgrid(u,v);X=U.*cos(V);Y=U.*sin(V);Z=5*V;figure(10),title( 纽带 )mesh(X,Y,Z)axisequalaxisoff
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/150860.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...