《使用Matlab画出圆台圆锥圆柱》由会员分享,可在线阅读,更多相关《使用Matlab画出圆台圆锥圆柱(5页珍藏版)》请在人人文库网上搜索。

1、用Matlab画圆柱圆台圆锥自己建一个M文件,命名任意,如tu.m在命令窗口输入:tu%以下为tu.m文件clcclear all%圆柱X,Y,Z=cylinder(15.7,20);h=1.22*Z;surf(X,Y,h);hold on%圆台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=0 0 1.22;%底面中心坐标X2=0 0 1.22+h1;%顶面中心坐标L2=15.7-2.6/tan(a);r=15.7 L2;n=20;cyl_color=b;closed。

2、=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);grid on%r=0:0.1:3.2;R=0:0.1:15.7;%alpha=0:pi/20:2*pi;%角度0,2*pi%x=R*cos(alpha);%y=R*sin(alpha);%a=39.0;b=12.06;%h=1.22+R。

3、.*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)% This function constructs a cylinder connecting two center points % % Usage :% Cone,EndPlate1,EndPlate2 = Cone(X1,X2,R,n,cyl_color,closed,lines)% % Cone-Ha。

4、ndle of the cone% EndPlate1-Handle of the Starting End plate% EndPlate2-Handle of the Ending End plate% X1 and X2 are the 3x1 vectors of the two points% R is the radius of the cylinder/cone R(1) = start radius, R(2) = end radius% n is the no. of elements on the cylinder circumference (more refined)%。

5、 cyl_color is the color definition like r,b,0.52 0.52 0.52% closed=1 for closed cylinder or 0 for hollow open cylinder% lines=1 for displaying the line segments on the cylinder 0 for only% surface% % Typical Inputs% X1=10 10 10;% X2=35 20 40;% r=1 5;% n=20;% cyl_color=b;% closed=1;% % NOTE: There is。

6、 a MATLAB function cylinder to revolve a curve about an% axis. This Cylinder provides more customization like direction and etc%圆台的函数,文件名为Cone.m% Calculating the length of the Conelength_cyl=norm(X2-X1);% Creating 2 circles in the YZ planet=linspace(0,2*pi,n);xa2=R(1)*cos(t);xa3=R(1)*sin(t);xb2=R(2)。

7、*cos(t);xb3=R(2)*sin(t);% Creating the points in the X-Directionx1=0 length_cyl;% Creating (Extruding) the cylinder points in the X-Directionsxx1=repmat(x1,length(xa2),1);xx2=xa2 xb2;%xx2=repmat(x2,1,2);xx3=xa3 xb3;%xx3=repmat(x3,1,2);% Drawing two filled cirlces to close the cylinderif closed=1hold。

8、 onEndPlate1=fill3(xx1(:,1),xx2(:,1),xx3(:,1),r);EndPlate2=fill3(xx1(:,2),xx2(:,2),xx3(:,2),r);end% Plotting the cylinder along the X-Direction with required length starting% from OriginCone=mesh(xx1,xx2,xx3);% Defining Unit vector along the X-directionunit_Vx=1 0 0;% Calulating the angle between th。

9、e x direction and the required direction% of Cone through dot productangle_X1X2=acos( dot( unit_Vx,(X2-X1) )/( norm(unit_Vx)*norm(X2-X1) )*180/pi;% Finding the axis of rotation (single rotation) to roate the Cone in% X-direction to the required arbitrary direction through cross productaxis_rot=cross。

10、(1 0 0,(X2-X1) );% Rotating the plotted Cone and the end plate circles to the required% anglesif angle_X1X2=0 % Rotation is not needed if required direction is along Xrotate(Cone,axis_rot,angle_X1X2,0 0 0)if closed=1rotate(EndPlate1,axis_rot,angle_X1X2,0 0 0)rotate(EndPlate2,axis_rot,angle_X1X2,0 0 。

11、0)endend% Till now Cone has only been aligned with the required direction, but% position starts from the origin. so it will now be shifted to the right% positionif closed=1set(EndPlate1,XData,get(EndPlate1,XData)+X1(1)set(EndPlate1,YData,get(EndPlate1,YData)+X1(2)set(EndPlate1,ZData,get(EndPlate1,ZD。

12、ata)+X1(3)set(EndPlate2,XData,get(EndPlate2,XData)+X1(1)set(EndPlate2,YData,get(EndPlate2,YData)+X1(2)set(EndPlate2,ZData,get(EndPlate2,ZData)+X1(3)endset(Cone,XData,get(Cone,XData)+X1(1)set(Cone,YData,get(Cone,YData)+X1(2)set(Cone,ZData,get(Cone,ZData)+X1(3)% Setting the color to the Cone and the e。

13、nd platesset(Cone,AmbientStrength,1,FaceColor,cyl_color,FaceLighting,gouraud);%,EdgeColor,none)if closed=1set(EndPlate1 EndPlate2,AmbientStrength,1,FaceColor,cyl_color,FaceLighting,gouraud);%,EdgeColor,none)elseEndPlate1=;EndPlate2=;end% If lines are not needed making it disapearif lines=0set(Cone,E。

14、dgeAlpha,0)end%shading faceted % faceted flat interp;%camlight; %light;%lighting gouraud; %flat gouraud phong nonematerial shiny; %shiny dull metal%colormap(bone)%camlight headlight;%light(Style,local,Position,720 0 500);%light(Style,local,Position,0 480 500);参考文献:http:/www.matlabsky.com/thread-273-1-1.html。

matlab求圆台模型,使用Matlab画出圆台圆锥圆柱相关推荐

  1. matlab中画灯笼,新编使用Matlab画出圆台圆锥圆柱.doc

    新编使用Matlab画出圆台圆锥圆柱.doc 用Matlab画圆柱圆台圆锥 自己建一个M文件,命名任意,如tu.m 在命令窗口输入:tu %以下为tu.m文件 clc clear all %圆柱 [X ...

  2. matlab画圆柱,使用Matlab画出圆台圆锥圆柱

    <使用Matlab画出圆台圆锥圆柱>由会员分享,可在线阅读,更多相关<使用Matlab画出圆台圆锥圆柱(5页珍藏版)>请在人人文库网上搜索. 1.用Matlab画圆柱圆台圆锥自 ...

  3. matlab高斯白噪声频谱图,如何用MATLAB产生高斯白噪声,并且画出图形?

    如何用MATLAB产生高斯白噪声,并且画出图形? 来源:互联网  宽屏版  评论 2009-06-19 02:34:10 分类: 电脑/网络 >> 程序设计 >> 其他编程语言 ...

  4. matlab数值拟合r2_用MATLAB求RMSE怎么用MATLAB计算均方误差

    用MATLAB求RMSE 怎么用MATLAB计算均方误差 www.zhiqu.org     时间: 2020-12-07 function f=RMSE(h1,h2) %RMSE return RM ...

  5. 同步电机matlab设计,同步发电机matlab仿真 同步电机模型的MATLAB仿真毕业设计.doc...

    同步发电机matlab仿真 同步电机模型的MATLAB仿真毕业设计 PAGE PAGE 1 同步发电机matlab仿真 同步电机模型的MATLAB仿真毕业设计 导读:就爱阅读网友为您分享以下" ...

  6. 求ar模型参数matlab,AR模型的参数估计

    AR模型的参数估计 一.AR模型概述 AR模型属于随机信号参数模型的一种.在AR模型中,随机信号x(n)由本身的若干次过去值x(n−k)和当前的激励值w(n)线性组合产生. x ( n ) = w ( ...

  7. 用MATLAB实现高斯投影正反算且画出高斯投影图形

    具体代码如下: 使用matlab编程实现 clear % 选取画图的区域 for i = 60:1:120[P0(i-59,1),P0(i-59,2)]=GSBL2xym(0,i,90);[P1(i- ...

  8. matlab 求obb,实验六MATLAB神经网络工具箱DOC

    实验六MATLAB神经网络工具箱DOC 实验七MATLAB神经网络工具箱一.实验目的1.掌握 Matlab 对感知器网络的构建与训练方法.2.掌握 Matlab 对线性神经网络的构建与训练方法.3.掌 ...

  9. matlab求微分方程同届,Matlab学习——求解微分方程(组)

    介绍: 1.在 Matlab 中,用大写字母 D 表示导数,Dy 表示 y 关于自变量的一阶导数,D2y 表示 y 关于自变量的二阶导数,依此类推.函数 dsolve 用来解决常微分方程(组)的求解问 ...

最新文章

  1. numpy库学习 向量 矩阵 均为有两个[[ ,而秩为1的数组只有一个[ np.array([[]]) 与np.array([])的区别
  2. JAVA实现调整数组顺序使奇数位于偶数前面问题(《剑指 offer》)
  3. Redis的数据类型详解
  4. ActivityGroup中的子Activity创建Dialog:android.view.WindowManager$BadTokenException: U
  5. python多级网址爬取_python-29:多级页面爬取源码
  6. 数组元素前移后移 RUNOOB python练习题 68
  7. CodeForces 444C 节点更新求变化值的和
  8. 网页设计上机考试原题_全国计算机三级信息安全考试 经验分享
  9. 写 飞秋 程序,就是把简单的事情重复的做好
  10. 经理必看的8个管理网站
  11. ubuntu10.04添加账户示例
  12. RecyclerView onClick
  13. linux运行非法指令,illegal instruction非法指令的解决思路
  14. Google验证码ReCaptcha V3
  15. Matlab中MatPower模块的安装流程
  16. 如何用计算机发匿名短信,电脑如何给手机发信息_电脑匿名给手机发短信
  17. 使用MATLAB任意修改图片像素大小
  18. 如何发布类Excel的管理软件
  19. 为什么巡检在工业生产中如此重要?
  20. android安卓远程协助控制电脑PC端

热门文章

  1. 私有化的IM即时通讯平台,企业首选的沟通工具
  2. 小米8探索版android版本,小米8透明探索版三个月使用体验
  3. 路由器映射 局域网开外网设置
  4. 卿苏德博士:关于区块链的真正落地,这4大应用场景很靠谱
  5. 实施质量保证-管理过程
  6. 解决局域网内无法访问某个主机的问题
  7. C语言float有效位数为7位?
  8. 联想460A笔记本ubuntu下关闭独立显卡
  9. 2021-2027全球与中国虹膜识别机市场现状及未来发展趋势
  10. 干掉 Swagger-ui !试试这个新工具