Mercurial > hg > octave-lyh
diff scripts/plot/sphere.m @ 7191:b48a21816f2e
[project @ 2007-11-26 21:24:32 by jwe]
author | jwe |
---|---|
date | Mon, 26 Nov 2007 21:24:33 +0000 |
parents | e8d953d03f6a |
children | dd88d61d443f |
line wrap: on
line diff
--- a/scripts/plot/sphere.m +++ b/scripts/plot/sphere.m @@ -29,7 +29,7 @@ ## @seealso{peaks} ## @end deftypefn -function [xx,yy,zz] = sphere (h, n) +function [xx, yy, zz] = sphere (h, n) have_h = false; if (nargin > 1 && isscalar (h) && ishandle (h)) @@ -40,21 +40,19 @@ n = 20; endif have_h = true; + elseif (nargin == 1) + n = h; else - if (nargin == 1) - n = h; - else - n = 20; - endif + n = 20; endif theta = linspace (0, 2*pi, n+1); phi = linspace (-pi/2, pi/2, n+1); [theta,phi] = meshgrid (theta, phi); - x = cos(phi).*cos(theta); - y = cos(phi).*sin(theta); - z = sin(phi); + x = cos (phi) .* cos (theta); + y = cos (phi) .* sin (theta); + z = sin (phi); if (nargout > 0) xx = x;