sample file to create a solid cylinder with two disks on both sides
0001 %sample file to create a solid cylinder with two disks on both sides 0002 cyl_radius=0.75; 0003 cyl_height = 0.290; 0004 0005 %create a unit height cylinder with 100 points. Radius 75 0006 [X,Y,Z] = cylinder([cyl_radius], 100); 0007 %Multiply Z by height 0008 Z=Z*cyl_height; 0009 0010 %Save in stl format, create new file 0011 surf2stl('link0.stl', X, Y, Z, 'ascii', 'w'); 0012 0013 %now create a disk, bottom 0014 radius = linspace(0,cyl_radius,10); % For ten rings 0015 theta = (pi/180)*[0:10:360]; % For eight angles 0016 [R,T] = meshgrid(radius,theta); % Make radius/theta grid 0017 X = R.*cos(T); % Convert grid to cartesian coordintes 0018 Y = R.*sin(T); 0019 %Z = 0.*X; %(corresponding values of Z in terms of X and Y) 0020 %surf(X,Y,Z) 0021 %append this solid to already created file, bottom disk 0022 surf2stl('link0.stl', X, Y, 0.*X, 'ascii', 'a+'); 0023 %top disk 0024 surf2stl('link0.stl', X, Y, cyl_height.*ones(size(X,1), size(X,2)), 'ascii', 'a+'); 0025 %top disk 0026 %Z = cyl_height.*X; %(corresponding values of Z in terms of X and Y) 0027 %append