《使用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画出圆台圆锥圆柱

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

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

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

  3. matlab中如何画圆锥,使用Matlab画出圆台圆锥圆柱

    用Matlab画圆柱圆台圆锥 自己建一个M文件,命名任意,如tu.m 在命令窗口输入:tu %以下为tu.m文件 clc clear all %圆柱 [X,Y,Z]=cylinder(15.7,20) ...

  4. matlab怎么画x 1,matlab画出y=1 (x 1)的函数曲线

    请matlab高手教教 matlab编写一段程序,画出函数y=x^3*e^(-x^2),-1 clearx=-1:0.01:1;y=(x.^3).*exp(-x.^2);plot(x,y);title ...

  5. 画出序列的图形matlab,江恩时间序列怎么画,如何在matlab上绘制基于时间序列的图形...

    Q1:如何在matlab上绘制基于时间序列的图形 ..flag.. Q2:怎样用spss软件画出时间序列图 第一步:定义时间.步骤:数据-定义日期.有许多种日期模式,依实际情况定. 第二步:创建模型. ...

  6. matlab 汽车 流场,matlab画流场图

    基于 Matlab 分布式工具箱的流场计算及其可视化 蔡群;周美莲;段杰峰;李青... 基于 MATLAB 和 CFD 数据库的流场可视化的实现 [J], 晏畅 5.基于 VB 与 MATLAB 混合 ...

  7. matlab 画实心矩形,graphics画实心矩形

    C程序设计(根据用户的输入画矩形) 指导老师:赵亚娟 学生:陈文川 学号:06 ? ...? ? #include "graphics.h" #include "coni ...

  8. matlab以空间的点画球,3D空间画空洞小球Matlab程序

    3D空间画空洞小球Matlab程序 3D空间画空洞小球Matlab程序 有时候在三维空间中,需要画出很多的空洞小球.可以使用入戏的代码! clear all clc; [x,y,z]=sphere(1 ...

  9. 在matlab中画多个图,Matlab在一个图形窗口里画多个图形的详细教程

    原创Matlab在一个图形窗口里画多个图形的详细教程 编辑:佚名 来源:PC下载网时间:2019-11-18 13:35:08 对于Matlab软件各位应该还有不懂的地方,比如说想在一个图形窗口里画多 ...

最新文章

  1. 一个97年的IT人创业历程中的总结和感悟
  2. Java命令行界面(第4部分):命令行
  3. [ZJOI2010]贪吃的老鼠
  4. 《信息学奥赛一本通 提高篇》
  5. css-选择器-进阶-属性选择器-组选择器-nth选择器
  6. 中职计算机老师培训总结报告,中职计算机教师个人工作总结范文5篇.doc
  7. linux开启hadoop服务,Hadoop 2.7.4 关闭与启动
  8. [转]Kaldi语音识别
  9. php替代换行符号,php换行符号替换与过滤例子
  10. 从 Resource Hacker 到 Heaventools PE Explorer 1.99 R6
  11. 计算机共享文件登录人员记录,如何查看共享文件夹的访问记录,查看共享文件访问日志?...
  12. Java视频教程,最新全套Java教程!
  13. java 数据结构和算法 排序
  14. WPF图片背景色过滤
  15. 基于搜狗微信爬取微信公众号的文章
  16. 学习笔记(2):8小时学会HTML网页开发-网页布局之切切豆腐
  17. php鼠标悬浮显示,CSS3实现鼠标悬停显示扩展内容
  18. BadCopyPro 3.75 Build0608 注册码
  19. OpenFlow:Enabling Innovation in Campus Networks 译文
  20. css 实现蒙版效果

热门文章

  1. 查看linux的超级块
  2. Win10纯净版电脑开机黑屏有鼠标怎么办?
  3. 【✨十五天搞定电工基础】基本放大电路
  4. ArrayList类
  5. MapReduce and Parallel DBMSs Friends or Foes
  6. 27,verilog中整数运算的位宽和符号规则
  7. 去掉导航栏下边的横条
  8. 关键工具:如何知道自己擅长什么?
  9. c语言 《显示器》,C语言基础:你知道吗,对于C语言来说我们的显示器只是一个文件...
  10. A Lip Sync Expert Is All You Need for Speech to Lip Generation In The Wild 翻译