INFAMPLITUDECLIP - Perform infinite amplitude clipping on singnal

Program code:

function xout = infamplitudeclip(xin,options)

%   AUTHOR : Peter Soendergaard.

% ------ Checking of input parameters ---------

error(nargchk(1,2,nargin));

if ~isnumeric(x) || ~isvector(x)
  error('RMS: Input must be a vector.');
end;

% ------ Computation --------------------------

% Preserve the RMS value for later, should we need it.
xin_rms = rms(xin);

% Do the actual clipping.
xout = sign(xin);

% Set the RMS value, if needed.
if nargin>1
  switch(lower(options))
   case {'rms'}
    xout=xout/rms(xout)*xin_rms;
   otherwise
    error('Unknown option: %s',options);
  end;
end;