function out = genericseed(seed);
% GENERICSEED   Seed for random number generators.
%
% NEWSEED = GENERICSEED(SEED) generates a new seed to be used by the
% randon number generators. If SEED is empty, the clock is used to 
% generate a seed. 
%
% NEWSEED = GENERICSEED generates a seed for the randon number generators
% using the string 'RCAST'.
%
% See also: RAND, RANDN, RANDATOM, RANDUMAT, RANDUSS

% Copyright 2004 The MathWorks, Inc.

if nargin==0
   seed = sum(double('RCAST'));
end

if isempty(seed)
   x = clock;
   while isequal(x,clock)
      % wait for clock to change a little bit so that x(6) is different
   end
   out = ceil(100000*x(6));
elseif isa(seed,'char')
   out = sum(double(seed));
else
   out = seed;
end
