% FIX FIX Round Towards Zero
% 
% Usage
% 
% Rounds the argument array towards zero.  The syntax for its use is
% 
%    y = fix(x)
% 
% where x is a numeric array.  For positive elements of x, the output
% is the largest integer smaller than x.  For negative elements of x
% the output is the smallest integer larger than x.  For complex x,
% the operation is applied seperately to the real and imaginary parts.

% Copyright (c) 2002-2007 Samit Basu
% Licensed under the GPL

function y = fix(x)
  if (isreal(x))
    y = x;
    y(x>0) = floor(x(x>0));
    y(x<0) = ceil(x(x<0));
  else
    y = fix(real(x)) + i*fix(imag(x));
  end
  

