| Fixed-Point Toolbox™ | ![]() |
c = F.sub(a,b)
c = F.sub(a,b) subtracts objects a and b using fimath object F. This is helpful in cases when you want to override the fimath objects of a and b, or if the fimath objects of a and b are different.
a and b must have the same dimensions unless one is a scalar. If either a or b is scalar, then c has the dimensions of the nonscalar object.
If either a or b is a fi object, and the other is a MATLAB® built-in numeric type, then the built-in object is cast to the word length of the fi object, preserving best-precision fraction length.
In this example, c is the 32-bit difference of a and b with fraction length 16.
a = fi(pi);
b = fi(exp(1));
F = fimath('SumMode','SpecifyPrecision',...
'SumWordLength',32,'SumFractionLength',16);
c = F.sub(a, b)
c =
0.4233
DataTypeMode: Fixed-point: binary point scaling
Signed: true
WordLength: 32
FractionLength: 16
RoundMode: nearest
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: SpecifyPrecision
SumWordLength: 32
SumFractionLength: 16
CastBeforeSum: true
c = F.sub(a,b) is equivalent to
a.fimath = F; b.fimath = F; c = a - b;
except that the fimath properties of a and b are not modified when you use the functional form.
add, divide, fi, fimath, mpy, numerictype
![]() | stripscaling | subsasgn | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |