第十二节--MatLab绘图-3D.ppt

上传人:本田雅阁 文档编号:2969838 上传时间:2019-06-15 格式:PPT 页数:70 大小:3MB
返回 下载 相关 举报
第十二节--MatLab绘图-3D.ppt_第1页
第1页 / 共70页
第十二节--MatLab绘图-3D.ppt_第2页
第2页 / 共70页
第十二节--MatLab绘图-3D.ppt_第3页
第3页 / 共70页
第十二节--MatLab绘图-3D.ppt_第4页
第4页 / 共70页
第十二节--MatLab绘图-3D.ppt_第5页
第5页 / 共70页
点击查看更多>>
资源描述

《第十二节--MatLab绘图-3D.ppt》由会员分享,可在线阅读,更多相关《第十二节--MatLab绘图-3D.ppt(70页珍藏版)》请在三一文库上搜索。

1、MatLab绘图,三维图形,clf;t=(pi*(0:1000)/1000); y1=sin(t);y2=sin(10*t);y12=sin(t).*sin(10*t); subplot(2,2,1),plot(t,y1);axis(0,pi,-1,1) subplot(2,2,2),plot(t,y2);axis(0,pi,-1,1) subplot(position,0.2,0.05,0.6,0.45) plot(t,y12,b-,t,y1,-y1,r:);axis(0,pi,-1,1),三维图形,x,y = meshgrid(-3:0.3:3,-2:0.3:2); z=(x.2-2*x)

2、.*exp(-x.2-y.2-x.*y); mesh(x,y,z) axis(-3,3,-2,2,-0.7,1.5) colorbar figure,surf(x,y,z), axis(-3,3,-2,2,-0.7,1.5),colorbar,三维图形,三维线的绘图函数plot3 plot3(u1,v1,w1,u2,v2,w2) 空间的直线 plot3(x1;x2,y1;y2,z1;z2) ps.三维图形的注释中,除了用zlabel标注z轴外,其他二维图形中的函数都可使用。,三维图形,t=0:pi/50:10*pi; plot3(sin(t),cos(t),t) title(Helix),xl

3、abel(sin(t),ylabel(cos(t),zlabel(t); text(0,0,0,Origin),三维图形,三维图形,例,作一线框盒 盒子尺寸为 Lx*Ly*Lz. 创建函数boxplot3,画出盒子六个面的四条边。盒子位置和方向由两个对角坐标P(x0,y0,z0)和P(x0+Lx,y0+Ly,z0+Lz)确定。 boxplot3(1,1,1,3,5,7) boxplot3(4,6,8,4,5,1) boxplot3(8,11,9,1,1,1),三维图形,function boxplot3(x0,y0,z0,lx,ly,lz) %(0,0,0) ,(1,1,1) x=zeros(

4、1,8);x(1:4)=x0;x(5:8)=x0+lx; % x=0 0 0 0 1 1 1 1 y=zeros(1,8);y(1:8)=y0;y(3:4)=y0+ly;y(7:8)=y0+ly; z=zeros(1,8);z(1:8)=z0;z(2:3)=z0+lz;z(6:7)=z0+lz; %y= 0 0 1 1 0 0 1 1 %z= 0 1 1 0 0 1 1 0 index=zeros(6,5); index(1,:)=1:4 1; index(2,:)=5:8 5; index(3,:)=1 2 6 5 1; index(4,:)=4 3 7 8 4; index(5,:)=2

5、6 7 3 2; index(6,:)=1 5 8 4 1; for k=1:6 plot3(x(index(k,:),y(index(k,:),z(index(k,:) hold on end,三维图形,三维图形,柱形图cylinder x,y,z=cylinder x,y,z=cylinder(r) x,y,z=cylinder(r,n) cylinder cylinder(100,100),三维图形,三维图形,t=0:pi/10:2*pi; cylinder(2+cos(t);,三维图形,X=0:.2:pi; R=exp(-X.2/2).*sin(X); % plot(R,X) % ax

6、is(square) figure; x,y,z=cylinder(R,20); surf(x,y,z*pi) axis(-0.6,0.6,-0.6,0.6,0,pi),三维图形,三维图形,三维饼图pie3 x=1 3 5 7 4; idex=0 0 1 0 1; pie3(x,idex) legend(x,y,z,m,n),三维图形,曲面mesh mesh(x1,x2,z),三维图形,三维图形,Hidden on and hidden off x,y,z=sphere(12); subplot(1,2,1), mesh(x,y,z),title(Opaque) hidden on, axis

7、 off subplot(1,2,2),mesh(x,y,z), title(transparent),hidden off, axis off,三维图形,三维等值线图contour3 contour3(x,y,z) % (z) 默认xy为1:n,1:m xx1=linspace(-3,3,15); xx2=linspace(-3,13,17); x1,x2=meshgrid(xx1,xx2); z=x1.4 + 3*x1.2 - 2*x1 + 6 - 2*x2.*x1.2 + x2.2-2*x2; contour3(x1,x2,z),三维图形,contour3(x1,x2,z,100),三维

8、图形,x,y,z=peaks(30); surf(x,y,z); figure; contour3(x,y,z,16), grid,z = 3*(1-x).2.*exp(-(x.2) - (y+1).2) . - 10*(x/5 - x.3 - y.5).*exp(-x.2-y.2) . - 1/3*exp(-(x+1).2 - y.2);,三维图形,数据的二维等值线图contour x,y,z=peaks(30); contour(x,y,z); contour(x,y,z,16);,三维图形,Pcolorsurf的二维等效函数 x,y,z=peaks(30); pcolor(x,y,z),

9、三维图形, x,y,z=peaks(30); pcolor(x,y,z) shading interp,三维图形, x,y,z=peaks(30); pcolor(x,y,z) shading interp hold on contour(x,y,z,19,k) hold off,三维图形,其他三维图形函数quiver,waterfall,fill3,clabel x,y,z=peaks(30); waterfall(x,y,z) %waterfall 与函数mesh一样,不过他的网格线在x轴方向出现,三维图形,x,y,z=peaks(30); DX,DY=gradient(z,.5,.5);

10、 contour(x,y,z,10),hold on quiver(x,y,DX,DY) hold off,三维图形,fill3与fill类似 fill3(x,y,z,c) %使用数组x,y,z作为多变形的顶点,而c作为指定颜色。 clabel 给等值线图标上高度值,这样做时,clabel需要contour等值线矩阵的输出 x,y,z=peaks(30); cs=contour(x,y,z,8) clabel(cs), xlabel(),三维图形,meshc surfc x,y,z=peaks(30); meshc(x,y,z) ,三维图形, x,y,z=peaks(30); surfc(x,

11、y,z) ,三维图形,meshz surfl Meshz: 在网格周围画一个curtain图,起到参考平面的作用 meshz(peaks),三维图形,Surfl:用colormap-based lighting绘表面图 Surfl(x,y,z):用默认的光源方向设置和默认的阴影模型光线系数创建三维阴影表面图。 Surfl(light):用光线对象生成一个彩色的有明暗调子的表面 Surfl(,s):指定光源方向,三维图形, surfl(peaks(30) shading interp colormap (gray) colormap copper,三维图形,图形的颜色1) colormap co

12、lormap (map) colormap (default) cmap=colormap autumn 从红色向桔黄色,黄色过渡 bone 灰色图,具有较高的蓝色组分 colorcube 提供更多的灰色,纯红,纯绿,和纯蓝 cool 有青色和洋红阴影组成的颜色 copper 在黑色和古铜色之间平滑过渡,三维图形,flag 由红色白色蓝色和黑色组成 gray 返回线形灰色图 hot 由黑色 红色 橘红色 黄色和白色之间平滑过渡 hsv 变化色度-饱和度颜色模型中的色度成分。 jet 在蓝色青色黄色橘红色红色之间过渡 lines 生成由坐标轴colororder属性指定的色图和灰色阴影 pink

13、 summer spring white winter,三维图形,图形的颜色2) shading shading flat /faceted /interp,Shading flat shading faceted shading interp,三维图形,图形的颜色3) colorbar colorbar (vert) colorbar (horiz),三维图形,三维图形的视图控制view view(az,el) view(az,el) AZ = -37.5, EL = 30 is the default 3-D view. AZ = 0, EL = 90 is overhead and th

14、e default 2-D view. AZ = EL = 0 looks directly up the first column of the matrix. AZ = 180 is behind the matrix.,三维图形,peaks(40); view(0,0) view(0,90) view(45,45),三维图形,三维图形的光照lighting camlighting lighting flat 选择平面光照 lighting gouraud 选择gouraud光照 lighting phong 选择phong光照 light none 没有光照,三维图形,例:三位物体的旋转

15、和转换 从一点到另一点的转换公式 X=Lx+a11*x+a12*y+a13*z Y=Ly+a21*x+a22*y+a23*z Z=Lz+a31*x+a32*y+a33*z,三维图形,function Xrt,Yrt,Zrt = EulerAngles1(psi,chi,phi,Lx,Ly,Lz,x,y,z) R= cos(psi) * cos(chi), -cos(psi) * sin(chi) ,sin(psi); cos(phi) * sin(chi) + sin(phi) * sin(psi) * cos(chi),cos(phi) * cos(chi) - sin(phi) * sin

16、(psi) * sin(chi), - sin(phi) * cos(psi); sin(phi) * sin(chi) - cos(phi) * sin(psi) * cos(chi),sin(phi) * cos(chi) + cos(phi) * sin(psi) * sin(chi) ,cos(phi)*cos(psi); Xrt=R(1,1)*x+R(1,2)*y+R(1,3)*z+Lx; Yrt=R(2,1)*x+R(2,2)*y+R(2,3)*z+Ly; Zrt=R(3,1)*x+R(3,2)*y+R(3,3)*z+Lz;,三维图形,生成圆环面 function x,y,z=ca

17、rtire(a,b) r=linspace(b-a,b+a,10) th=linspace(0,2*pi,22) xx=r*cos(th) yy=r*sin(th) zz=real(sqrt(a2-(sqrt(xx.2+yy.2)-b).2); x=xx xx; y=yy yy; z=zz -zz;,三维图形,生成圆盘 functionXD,YD,ZD = CarDisc(a,b) discr= linspace(0,b-a,7); th= linspace(0,2*pi,16); XD=discr*cos(th); YD=discr*sin(th); ZD=zeros(7,16),三维图形,圆环及圆环与内部圆盘的旋转,三维图形,生成长度为2*L2,直径为0.3(b-a)车轴 function XC,YC,ZC=CarShaft(a,b,L2) th=linspace(0,2*pi,16) XC,ZC=meshgrid(0.3*(b-a)*cos(th),-L2,L2); YC=meshgrid(0.3*(b-a)*sin(th),-L2,L2);,作业二,下式表示一外缘固定的方形薄膜,画出其形状及等高线图,图中在0=x=1及0=y=1时,每个方向使用25个网格点 w(x,y)=sin(2*pi*x)sin(3*pi*y),

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1