Plot cylinder

版本 1.0.0.0 (1.3 KB) 作者: sjye
Triangulated patch cylinder
1.3K 次下载
更新时间 2010/12/21

查看许可证

% Sample values
h = 10; % height
ra = 1.5; % radius

% Create constant vectors
tht = linspace(0,2*pi,100); z = linspace(0,h,20);

% Create cylinder
xa = repmat(ra*cos(tht),20,1); ya = repmat(ra*sin(tht),20,1);
za = repmat(z',1,100);

% To close the ends
X = [xa*0; flipud(xa); (xa(1,:))*0]; Y = [ya*0; flipud(ya); (ya(1,:))*0];
Z = [za; flipud(za); za(1,:)];

% Draw cylinder
[TRI,v]= surf2patch(X,Y,Z,'triangle');
patch('Vertices',v,'Faces',TRI,'facecolor',[0.5 0.8 0.8],'facealpha',0.8);
view(3); grid on; axis square; title('Cylinder','FontSize',12)

引用格式

sjye (2024). Plot cylinder (https://www.mathworks.com/matlabcentral/fileexchange/29804-plot-cylinder), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0