MATLAB: How to plot a prism

prism

hi. i tried to plot a prism with a n-sides base. i only could plot the 2 bases (for n =8). now i have no idea how to plot the faces. plz help me
n=8;
A=ones(n+1);
z1=2;h=3;
z=A(:,1)*z1;
zz=z+h;
t = 0:2*pi/n:2*pi;
x=cos(t);
y=sin(t);
plot3(x,y,z)
hold on
plot3(x,y,zz)
r.jpg

Best Answer

Use surf instead of plot3 if you want solid-appearing sides.
Try this:
figure
surf([x;x].', [y;y].', [z,zz], 'FaceColor','g')
grid on
% axis equal
% shading('interp')
The axis and shading calls are optional. Note that the surf arguments are two-column martices.