% torus.m theta = pi*(-24:1:24)/24; phi = pi*(-24:1:24)'/24; r = 2 + cos(phi); h = sin(phi); x = r*cos(theta); y = r*sin(theta); z = h*ones(size(theta)); surf(x,y,z);