function h_out = ellipse( x, y, rx, ry, npoints, c )
  
  if nargin < 3
    error( [ mfilename ' needs at least 3 input arguments.' ] );
  end
  
  if nargin < 4
   ry = [];
  end
  if isempty( ry )
    % Default: circle
    ry = rx;
  end
  
  if nargin < 5
    npoints = [];
  end
  if isempty( npoints )
    npoints = 300;
  end
  
  if nargin < 6
    c = [];
  end
  if isempty( c )
    c = 'b';
  end
  
  x = x(:);
  y = y(:);
  rx = rx(:);
  ry = ry(:);
  
  % Check for consistency
  n = [ length( x ), length( y ), length( rx ), length( ry ), length( npoints ), length( c ) ];
  if length( setdiff( unique( n ), 1 ) ) > 1
    error( [ mfilename ' needs parameters with consistent lengths. Each parameter must be a vector of either 1 or N values.' ] );
  end
  
  % Check whether we want to draw multiple ellipses
  nmax = max( n );
  if nmax > 1
    if n( 1 ) == 1
      x = repmat( x, nmax, 1 );
    end
    if n( 2 ) == 1
      y = repmat( y, nmax, 1 );
    end
    if n( 3 ) == 1
      rx = repmat( rx, nmax, 1 );
    end
    if n( 4 ) == 1
      ry = repmat( ry, nmax, 1 );
    end
    if n( 5 ) == 1
      npoints = repmat( npoints, nmax, 1 );
    end
    if n( 6 ) == 1
      c = repmat( c, nmax, 1 );
    end
  end
  
  old_ishold = ishold;
  
  hold on;
  for a = 1:nmax
    
    t = (0:npoints( a )) * 2 * pi / npoints( a );
    
    h( a ) = plot( x( a )+rx( a )*cos(t), y( a )+ry( a )*sin(t) );
    
    set( h( a ), 'Color', c( a ) );
    
  end

  if ~old_ishold
    hold off;
  end
  
  if nargout > 1
    h_out = h;
  end
  