Modulus after division for fi
objects
M = mod(X,Y)
M = mod(X,Y)
if Y ~= 0
,
returns Xn.*Y
, where n = floor(X./Y)
.
The inputs X
and Y
must be real
arrays of the same size, or either can be a real scalar. For fixedpoint
or integer input arguments, the output data type is the aggregate
type of both input signedness, word lengths, and fraction lengths.
For floatingpoint input arguments, the output data type is the same
as the inputs.
The mod
function ignores and discards any fimath
attached
to the inputs. The output is always associated with the default fimath
.
The combination of fixedpoint and floatingpoint inputs is not currently supported.

Integer, fixedpoint, or floatingpoint array, or real scalar. 

Array of the same size as 

Result of modulus operation. If both inputs 
Calculate the mod
of two fi
objects.
% 7bit signed fixedpoint object x = fi(3,1,7,0); % 15bit signed fixedpoint object y = fi(2,1,15,0); M1 = mod(x,y) M1 = 1 DataTypeMode: Fixedpoint: binary point scaling Signedness: Signed WordLength: 15 FractionLength: 0 M2 = mod(y,x) M2 = 1 DataTypeMode: Fixedpoint: binary point scaling Signedness: Signed WordLength: 15 FractionLength: 0
Convert the fi
inputs in the previous example
to double type, and calculate the mod
.
Mf1 = mod(double(x),double(y)) Mf1 = 1 Mf2 = mod(double(y),double(x)) Mf2 = 1