[X,Y,Z] = cylinder returns the x-,
y-, and z- coordinates of a cylinder
without drawing it. The returned cylinder has a radius equal to
1, 20 equally spaced points around its circumference, and
bases parallel to the xy-plane.
The function returns the x-, y-, and
z- coordinates as three
To draw the cylinder using the returned coordinates, use the
[X,Y,Z] = cylinder( returns the
x-, y-, and z-
coordinates of a cylinder with the specified profile curve,
r, and 20 equally spaced points around its
circumference. The function treats each element in
r as a
radius at equally spaced heights along the unit height of the cylinder.
Create and plot a cylinder with a radius equal to 1.
Specify the radius of a cylinder by including the input
r. Then, specify the height of the cylinder by modifying the returned
Z as coordinates of a cylinder with a radius of 4.
r = 4; [X,Y,Z] = cylinder(r);
Specify a height of 20 by modifying the
Z coordinate. Plot the cylinder.
h = 20; Z = Z*h; surf(X,Y,Z)
Create a cylinder and use the returned coordinates to plot multiple cylinders in different locations.
Create a cylinder defined by the profile function
2 + cos(t).
t = 0:pi/10:2*pi; r = 2 + cos(t); [X,Y,Z] = cylinder(r);
Plot the cylinder with the base centered at the origin.
Plot two more cylinders on top of the first cylinder.
hold on surf(X,Y,Z+1) surf(X,Y,Z+2)
r— Profile curve
Profile curve, specified as a vector.
each element in
r as a radius at equally spaced heights
along the unit height of the cylinder.
n— Number of points
Number of points around the cylinder circumference, specified as a positive whole number.
ax— Target axes
Target axes, specified as an
Axes object. If you do not
specify the axes, then
cylinder plots into the current