Modulus after division for
M = mod(X,Y)
M = mod(X,Y) if
Y ~= 0,
n = floor(X./Y).
Y must be real
arrays of the same size, or either can be a real scalar. For fixed-point
or integer input arguments, the output data type is the aggregate
type of both input signedness, word lengths, and fraction lengths.
For floating-point input arguments, the output data type is the same
as the inputs.
mod function ignores and discards any
to the inputs. The output is always associated with the default
The combination of fixed-point and floating-point inputs is not currently supported.
Integer, fixed-point, or floating-point array, or real scalar.
Array of the same size as
Result of modulus operation. If both inputs
mod of two
% 7-bit signed fixed-point object x = fi(-3,1,7,0); % 15-bit signed fixed-point object y = fi(2,1,15,0); M1 = mod(x,y) M1 = 1 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 15 FractionLength: 0 M2 = mod(y,x) M2 = -1 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 15 FractionLength: 0
fi inputs in the previous example
to double type, and calculate the
Mf1 = mod(double(x),double(y)) Mf1 = 1 Mf2 = mod(double(y),double(x)) Mf2 = -1