%gaussian.m %Create a 3D printable Plot of Gaussian curve %Steven Sahyun August 31, 2015 %University of Wisconsin - Whitewater %sahyuns@uww.edu clear; clf(); x = 0:.5:50; y = 0:.5:50; center = 25; xwidth = 10; ywidth = 10; zscale = 25; %this is to set the z-axis scale to have a good plot %z = x'*y; z = zscale*exp(-((x-center)./xwidth).^2)'*exp(-((y-center)./ywidth).^2); %Plot the surface surf(x,y,z); %convert to a 3D printable file; You need to have stlwrite.m and surf2solid.m by %Sven Holcombe in the same directory as this file. %See: http://jmumakerlab.blogspot.com/2013/11/exporting-stl-from-matlab.html % http://www.mathworks.com/matlabcentral/fileexchange/42876-surf2solid-make-a-solid-volume-from-a-surface-for-3d-printing % http://www.mathworks.com/matlabcentral/fileexchange/20922-stlwrite-filename--varargin- %functions minz = 0; maxz = zscale; c=255*((z+minz)/maxz); GaussianSurface = surf2solid(x, y, z); %surf2dxf('Gaussiandxf', x, y, z) %not working stlwrite('GaussianSurfacestl.stl',GaussianSurface)