Skip to content

cylinder

plot · scripts/plot/draw/cylinder.m

: [x, y, z] = cylinder ()
: [x, y, z] = cylinder (r)
: [x, y, z] = cylinder (r, n)
: h = cylinder (…)
: cylinder (ax, …)

Generate the surface of a body of revolution about the z axis.

The vector r gives the radius profile (default [1 1]); a scalar radius describes a straight cylinder. The circumference is sampled with n segments (default 20), so the result matrices have numel (r) rows and n+1 columns, the last column repeating the first. Row i lies at height (i-1)/(numel (r)-1).

With three output arguments the coordinate matrices are returned; otherwise the surface is drawn and its handle is returned.