function [] = phallus(l) % % PHALLUS % % The phallus(l) command constructs a 3-D rendition of % "The Little Brain" with total length as specified in l. % Phallus invoked with no arguments uses the default length % of 6. % if nargin == 0, l=6;, end % set up mesh and radius matrices x=-.3:.01:.3; [X,Y]=meshgrid(x); r1=(X.^2 + Y.^2).^.5; r2=((X+.17).^2+(Y+.17).^2).^.5; r3=((X+.17).^2+(Y-.17).^2).^.5; % calculate "pencil" z1=(sinc(pi/.14*r1)).^2; % claculate "erasers" z2=(.03-r2.^2).^.5; [n,m]=find(r2>=.1732); for i=1:length(n), z2(n(i),m(i))=0;, end z2=1.8*real(z2); z3=(.03-r3.^2).^.5; [n,m]=find(r3>=.1732); for i=1:length(n), z3(n(i),m(i))=0;, end z3=1.8*real(z3); % scale the whole "thing" z = l*z1 + (l/2+3)*z2 + (l/2+3)*z3; % plot "it" surf(X,Y,z) % Shade appropriately map = colormap; colormap([map(:,3) map(:,1) map(:,1)]); % Print positive message title('Have a Nice Day!')