资源简介
MATLAB画三维圆柱体的源代码,能够自己改参数改变圆柱的形状、大小
代码片段和文件信息
function [Cylinder EndPlate1 EndPlate2] = cylinder3(X1X2rncyl_colorclosedlines)
%
% This function constructs a cylinder connecting two center points
%
% Usage :
% [Cylinder EndPlate1 EndPlate2] = cylinder3(X1+20X2rn‘r‘closedlines)
%
% Cylinder-------Handle of the cylinder
% 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
% n is the no. of elements on the cylinder circumference (more--> refined)
% 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;
% n=20;
% cyl_color=‘b‘;
% closed=1;
%
%see more information please go to www.matlabsky.cn
% NOTE: There is a MATLAB function “cylinder“ to revolve a curve about an
% axis. This “Cylinder“ provides more customization like direction and etc
% Calculating the length of the cylinder
length_cyl=norm(X2-X1);
% Creating a circle in the YZ plane
t=linspace(02*pin)‘;
x2=r*cos(t);
x3=r*sin(t);
% Creating the points in the X-Direction
x1=[0 length_cyl];
% Creating (Extruding) the cylinder points in the X-Directions
xx1=repmat(x1length(x2)1);
xx2=repmat(x212);
xx3=repmat(x312);
% Drawing two filled cirlces to close the cylinder
if closed==1
hold on
EndPlate1=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 Origin
Cylinder=mesh(xx1xx2xx3);
% Definin
- 上一篇:nc文件的读取作图
- 下一篇:图像清晰度评价指标_Matlab
相关资源
- 图像清晰度评价指标_Matlab
- nc文件的读取作图
- MATLAB JPEG图像压缩
- matlab图像融合程序
- 导线网平差matlab程序
- ID3算法MATLAB实现,机器学习作业
- 基于颜色的matlab代码
- 图像分类模式识别算法源代码
- MATLAB直方图绘制代码
- matlab 一维传热问题
- matlab实现小波变换融合以及信息熵、
- 小波变换matlab
- matlab编写的地震剖面显示程序
- FMCW毫米波雷达测量呼吸心跳算法mat
- kld采样
- 以高斯塞德尔法和牛顿拉夫逊法为思
- 切比雪夫轨道拟合MATLAB代码
- matlab三维点坐标生成点云
- 改进灰色马尔科夫模型估测湖北省用
- 带时间窗的车辆路径规划问题的粒子
- 步长加速法寻优迭代
- Matlab GUI图像图形基础教程
- 人眼检测、疲劳驾驶检测,MATLAB代码
- 小波神经网络MAtlab工具箱
- 可以运行的GA 算法 ,matlab 编写
- CRC32的FPGA并行实现原理及MATLAB仿真
- DWT小波变换MATLAB
- 读取jiason测高卫星nc文件matlab代码
-
MATLAB_SIMUli
nk系统仿真超级学习手册 - Matlab图像分割法
评论
共有 条评论