n = 30; theta = (-n:2:n)/n*pi; phi = (-n:2:n)'/n*pi/2; cosphi = cos(phi); cosphi(1) = 0; cosphi(n+1) = 0; sintheta = sin(theta); sintheta(1) = 0; sintheta(n+1) = 0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% k = 1; x = k*cosphi*cos(theta); y = k/3*cosphi*sintheta; z = k/5*sin(phi)*[ones(1,n+1)]; surf(x,y,z,'FaceColor','yellow') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% hold on %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% k = 2; x = k*cosphi*cos(theta); y = k/3*cosphi*sintheta; z = k/5*sin(phi)*[NaN*zeros(1,5) ones(1,n-4)]; surf(x,y,z,'FaceColor','red') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% hold on %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% k = 3; x = k*cosphi*cos(theta); y = k/3*cosphi*sintheta; z = k/5*sin(phi)*[NaN*zeros(1,5) ones(1,n-4)]; surf(x,y,z,'FaceColor','cyan') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legend('k = 1', 'k = 2', 'k = 3') xlabel('x'), ylabel('y'), zlabel('z')