Code covered by the BSD License  

Highlights from
Plot cylinder

1.5

1.5 | 2 ratings Rate this file 11 Downloads (last 30 days) File Size: 1.3 KB File ID: #29804
image thumbnail

Plot cylinder

by sjye

 

21 Dec 2010

Triangulated patch cylinder

| Watch this File

File Information
Description

% 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)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
isodd, Local min, max, nearest neighbour

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
22 Dec 2010 Sean de

The entirety of this script is in the description. Basically this is an example of how to plot one specific cylinder with one specific color in an inefficient way. It also overwrites the stock CYLINDER function that is actually useful.

01 Dec 2011 Chris Taylor  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
cylinder sjye 22 Dec 2010 08:15:50
patch sjye 22 Dec 2010 08:15:50
repmat sjye 22 Dec 2010 08:15:50
3d sjye 28 Dec 2010 04:19:27
flipud sjye 28 Dec 2010 04:19:46
volume sjye 28 Dec 2010 04:19:54

Contact us at files@mathworks.com