function [xx,yy,zz]=ellipsoid(xc,yc,zc,xr,yr,zr,n)
%ELLIPSOID Generate ellipsoid.
%
% [X,Y,Z]=ELLIPSOID(XC,YC,ZC,XR,YR,ZR,N) generates three
% (N+1)-by-(N+1) matrices so that SURF(X,Y,Z) produces an
% ellipsoid with center (XC,YC,ZC) and radii XR, YR, ZR.
% 
% [X,Y,Z]=ELLIPSOID(XC,YC,ZC,XR,YR,ZR) uses N = 20.
%
% ELLIPSOID(...) and ELLIPSOID(...,N) with no output arguments
% graph the ellipsoid as a SURFACE and do not return anything.
%
% The ellipsoidal data is generated using the equation:
%
%  (X-XC)^2     (Y-YC)^2     (Z-ZC)^2
%  --------  +  --------  +  --------  =  1
%    XR^2         YR^2         ZR^2
%
% See also SPHERE, CYLINDER.

% Laurens Schalekamp and Damian T. Packer
% Copyright 1984-2000 The MathWorks, Inc. 
% $Revision: 1.5 $  $Date: 2000/09/03 05:33:22 $

error(nargchk(6,7,nargin));

if nargin == 6
	n=20; 
end

[x,y,z] = sphere(n);

x = xr*x+xc;
y = yr*y+yc;
z = zr*z+zc;
if(nargout == 0)
	surf(x,y,z)
else
	xx=x;
	yy=y;
	zz=z;
end
