新编使用matlab画出圆台圆锥圆柱

新编使用matlab画出圆台圆锥圆柱

ID:15881979

大小:63.00 KB

页数:32页

时间:2018-08-06

新编使用matlab画出圆台圆锥圆柱_第1页
新编使用matlab画出圆台圆锥圆柱_第2页
新编使用matlab画出圆台圆锥圆柱_第3页
新编使用matlab画出圆台圆锥圆柱_第4页
新编使用matlab画出圆台圆锥圆柱_第5页
资源描述:

《新编使用matlab画出圆台圆锥圆柱》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、用Matlab画圆柱圆台圆锥自己建一个M文件,命名任意,如tu.m在命令窗口输入:tu%以下为tu.m文件clcclearall%圆柱[X,Y,Z]=cylinder(15.7,20);h=1.22*Z;surf(X,Y,h);holdon%圆台a=25/180*pi;%可修改b=12.06/180*pi;%可修改r=3.2;%可修改h1=r*sin(a+b)/sin(a-b)*sin(a);%h1=0.66;X1=[001.22];%底面中心坐标X2=[001.22+h1];%顶面中心坐标L2=15.7-2.6/tan(a)

2、;r=[15.7L2];n=20;cyl_color='b';closed=1;lines=1;[cone,EndPlate1,EndPlate2]=Cone(X1,X2,r,n,cyl_color,closed,lines)%调用圆台的函数%圆锥[X2,Y2,Z2]=cylinder(L2:-0.2:0);h2=1.5;%可修改Z2=h2*Z2;Z2=Z2+ones(size(Z2))*(1.22+h1);surf(X2,Y2,Z2);gridon%r=0:0.1:3.2;R=0:0.1:15.7;%alpha=0:pi/2

3、0:2*pi;%角度[0,2*pi]%x=R*cos(alpha);%y=R*sin(alpha);%a=39.0;b=12.06;%h=1.22+R.*tan(b)+r.*sin(a);%[x,y]=meshgrid([-4:0.5:4]);%surf(h)新建一个M文件,如下命名为Cone.Mfunction[Cone,EndPlate1,EndPlate2]=Cone(X1,X2,R,n,cyl_color,closed,lines)%%Thisfunctionconstructsacylinderconnectingt

4、wocenterpoints%%Usage:%[Cone,EndPlate1,EndPlate2]=Cone(X1,X2,R,n,cyl_color,closed,lines)%%Cone-------Handleofthecone%EndPlate1------HandleoftheStartingEndplate%EndPlate2------HandleoftheEndingEndplate%X1andX2arethe3x1vectorsofthetwopoints%Ristheradiusofthecylinder/c

5、oneR(1)=startradius,R(2)=endradius%nistheno.ofelementsonthecylindercircumference(more-->refined)%cyl_coloristhecolordefinitionlike'r','b',[0.520.520.52]%closed=1forclosedcylinderor0forhollowopencylinder%lines=1fordisplayingthelinesegmentsonthecylinder0foronly%surfac

6、e%%TypicalInputs%X1=[101010];%X2=[352040];%r=[15];%n=20;%cyl_color='b';%closed=1;%%NOTE:ThereisaMATLABfunction"cylinder"torevolveacurveaboutan%axis.This"Cylinder"providesmorecustomizationlikedirectionandetc%圆台的函数,文件名为Cone.m%CalculatingthelengthoftheConelength_cyl=no

7、rm(X2-X1);%Creating2circlesintheYZplanet=linspace(0,2*pi,n)';xa2=R(1)*cos(t);xa3=R(1)*sin(t);xb2=R(2)*cos(t);xb3=R(2)*sin(t);%CreatingthepointsintheX-Directionx1=[0length_cyl];%Creating(Extruding)thecylinderpointsintheX-Directionsxx1=repmat(x1,length(xa2),1);xx2=[xa

8、2xb2];%xx2=repmat(x2,1,2);xx3=[xa3xb3];%xx3=repmat(x3,1,2);%Drawingtwofilledcirlcestoclosethecylinderifclosed==1holdonEndPlate1=fill3(xx1(

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。