cylinder
Generates the coordinates of a surface of revolution, by default a cylinder.
Category: Graphics > 2-D and 3-D Plots
Syntax
[X, Y, Z] = cylinder
A unit cylinder with 20 points around the circumference.
[X, Y, Z] = cylinder(r)
Revolves the radius profile r along a unit height.
[X, Y, Z] = cylinder(r, n)
Uses n points around the circumference.
cylinder(___)
With no output arguments, draws the surface.
Description
The profile vector r gives the radius at heights equally spaced between 0 and 1. A scalar r is treated as [r r], producing a straight cylinder, while [2 1] gives a cone frustum and [0 1] a cone. The matrices can be passed to surf or mesh; the seam column is repeated so the surface closes.
Input arguments
r- Scalar radius or vector of radii at equally spaced heights from 0 to 1.
n- Number of points around the circumference, 20 by default.
Output arguments
X, Y, Z- Matrices of size
numel(r)byn+1; rowkis the circle at heightZ(k,1).
Example
A vase profile
r = [1 1.4 1 0.6 1];
[X, Y, Z] = cylinder(r, 12);
disp(size(X))
disp(Z(:, 1)')
surf(X, Y, Z)
Output
5 13
0 0.2500 0.5000 0.7500 1.0000