% created: 	Nov  6 2011 
% author:  	Prashant Patil 
% email:   	ppatil@mit.edu
 

th = 0:(2*pi/100):2*pi;
r = 0:.2:5;

% create a polar grid
[thg, rg] = meshgrid(th,r);

 
f = inline('cos(5*th) + 6*exp(-r.^2)', 'th', 'r');
u = feval(f,thg,rg);

[X,Y,Z] = pol2cart(thg,rg,u);



% create a surface from the function
[X_out, Y_out, Z_out] = surf2solid(X, Y, Z);
 

% now output the surface
surf2stl('MathFunction.stl',X_out,Y_out,Z_out)


 







