% Plot a set of rods spaced out in a hexagonal array. figure(2);clf; hold on % Basic Cylinder form. r = 0.25; N = 35; Narray=3; [X,Y,Z] = cylinder(r,N); Z = Z *Narray; % Basic Cap Xc = r*cos(pi*[0:N]/N); Xc = [Xc ; Xc]; Yc = r*sin(pi*[0:N]/N); Yc = [Yc ; -Yc]; Zc = zeros(size(Xc)); % Plot out the Rods clear handle1 c1=1; for j=0:Narray;for k=0:Narray; handle1(c1)= surf(X+j+cos(pi/3)*k,Y+sin(pi/3)*k,Z); c1=c1+1; end; end; for j=1:length(handle1) % Set the colour of the Rods set(handle1(j),'FaceColor',[1.0 0.6 0.3]); set(handle1(j),'EdgeColor','none'); end % Put caps on the top of the rods clear handle2 c2=1; for j=0:Narray; for k=0:Narray; handle2(c2)=surf(Xc+j+cos(pi/3)*k,Yc+sin(pi/3)*k,Zc); c2=c2+1; handle2(c2)=surf(Xc+j+cos(pi/3)*k,Yc+sin(pi/3)*k,Zc+Narray); c2=c2+1; end; end; for j=1:length(handle2) % Set the colour of the caps. set(handle2(j),'FaceColor',[1.0 0.6 0.3]); set(handle2(j),'EdgeColor','none'); end % Set the Viewpoint and Lighting view(-70,40); daspect([1,1,1]) camlight lighting gouraud axis off