function mod_x = mod(x,modulus)
%MOD                                                [jMc 2/89]
%    mod(X,Y) returns the (real) part of X modulo Y,
%       where Y is a real scalar.
%       The result lies between 0.0 and Y (positive or negative).
%       operates element-by-element on the matrix X.
%  see also REM
 
mod_x = rem(modulus+rem(x,modulus),modulus);  % fix sign of remainder
 
