% 1. spheres and cylinders [x,y,z] = sphere(10); size(x) ans = 11 11 surf(x,y,z) [x,y,z] = sphere(100); surf(x,y,z) % tubes are made out of cylinders t = 0:0.1:2*pi; r = 0.5 + 0.5*sin(2*t); % we use the r to define the distance from % the axis of the cylinder [x,y,z] = cylinder(r); figure surf(x,y,z) r = 0.8 + 0.2*sin(2*t); [x,y,z] = cylinder(r); surf(x,y,z) hold on % let us put a sphere on top of the cylinder [x1,y1,z1] = sphere(100); % to lift the sphere we add 2*pi to the z1: size(z1) ans = 101 101 z2 = z1 + 2*pi*ones(101,101); % we added to the sampled heights in z1 % 2*pi in order to make z2 surf(x1,y1,z2) z3 = z1 + ones(101,101); figure surf(x,y,z); hold on surf(x1,y1,z3); % we can redefine the walls, permuting x, y, and z % cones are special cylinders figure cylinder([0 1]) hold on cylinder([1 0]) % note that cylinder, just as sphere makes samples [x5,y5,z5] = cylinder([1 0]); % we will lift the cone up, adding one to every % z-coordinate size(z5) ans = 2 21 z6 = z5 + ones(2,21); surf(x5,y5,z6) figure surf(x5,y5,z6) hold on cylinder([0,1]) % 2. cubic spline interpolation % to draw complicated pictures, we better use a script edit figure drawcar % we can change the directory cd c: pwd ans = C:\Documents and Settings\janv ls . .. .alice .drjava Application Data Cookies Desktop Favorites Local Settings My Documents NTUSER.DAT NetHood PrintHood Recent SPLUS_Home SendTo SimplePictureProperties.txt Start Menu Templates WINDOWS bluej drawcar.m gsview32.ini jacorb.properties matlec5.txt ntuser.dat.LOG ntuser.ini ntuser.pol openrct.properties vgalusr1.vr drawcar drawcar drawcar diary off