fimath Object Properties
Math, Rounding, and Overflow Properties
You can always write to the following properties of fimath
objects:
Property  Description  Valid Values 

CastBeforeSum  Whether both operands are cast to the sum data type before addition 
Note This property is hidden when the

MaxProductWordLength  Maximum allowable word length for the product data type 

MaxSumWordLength  Maximum allowable word length for the sum data type 

OverflowAction  Action to take on overflow 

ProductBias  Bias of the product data type 

ProductFixedExponent  Fixed exponent of the product data type 
Note The 
ProductFractionLength  Fraction length, in bits, of the product data type 
Note The 
ProductMode  Defines how the product data type is determined 

ProductSlope  Slope of the product data type 
Note $$ProductSlope=ProductSlopeAdjustmentFactor\times {2}^{ProductFixedExponent}$$ Changing one of these properties affects the others. 
ProductSlopeAdjustmentFactor  Slope adjustment factor of the product data type 
Note $$ProductSlope=ProductSlopeAdjustmentFactor\times {2}^{ProductFixedExponent}$$ Changing one of these properties affects the others. 
ProductWordLength  Word length, in bits, of the product data type 

RoundingMethod  Rounding method 

SumBias  Bias of the sum data type 

SumFixedExponent  Fixed exponent of the sum data type 
Note The 
SumFractionLength  Fraction length, in bits, of the sum data type 
Note The 
SumMode  Defines how the sum data type is determined 

SumSlope  Slope of the sum data type 
Note $$SumSlope\text{=}SumSlopeAdjustmentFactor\times {2}^{SumFixedExponent}$$ Changing one of these properties affects the others. 
SumSlopeAdjustmentFactor  Slope adjustment factor of the sum data type 
Note $$SumSlope\text{=}SumSlopeAdjustmentFactor\times {2}^{SumFixedExponent}$$ Changing one of these properties affects the others. 
SumWordLength  Word length, in bits, of the sum data type 

For details about these properties, refer to the Set fi Object Properties. To learn how to
specify properties for fimath
objects in FixedPoint Designer™ software, refer to Setting fimath Object Properties.
How Properties are Related
Sum data type properties
The slope of the sum of two fi
objects is related to the
SumSlopeAdjustmentFactor
and
SumFixedExponent
properties by
$$SumSlope\text{=}SumSlopeAdjustmentFactor\times {2}^{SumFixedExponent}$$
If any of these properties are updated, the others are modified accordingly.
In a FullPrecision
sum, the resulting word length is
represented by
$${W}_{s}=\text{integerlength}+{F}_{s}$$
where
$$\text{integerlength}=\mathrm{max}\left({W}_{a}{F}_{a},{W}_{b}{F}_{b}\right)+\mathrm{ceil}\left(\mathrm{log}2\left(NumberOfSummands\right)\right)$$
and
$${F}_{s}=\mathrm{max}({F}_{a},{F}_{b})$$
When the SumMode
is set to KeepLSB
, the
resulting word length and fraction length is determined by
$$\begin{array}{l}{W}_{s}=\text{specifiedinthe}\text{SumWordLength}\text{property}\\ {F}_{s}=\mathrm{max}({F}_{a},{F}_{b})\end{array}$$
When the SumMode
is set to KeepMSB
, the
resulting word length and fraction length is determined by
$$\begin{array}{l}{W}_{s}=\text{specifiedinthe}\text{SumWordLength}\text{property}\\ {F}_{s}={W}_{s}\text{integerlength}\end{array}$$
where
$$\text{integerlength}=\mathrm{max}\left({W}_{a}{F}_{a},{W}_{b}{F}_{b}\right)+\mathrm{ceil}\left(\mathrm{log}2\left(NumberOfSummands\right)\right)$$
When the SumMode
is set to
SpecifyPrecision
, you specify both the word and fraction
length or slope and bias of the sum data type with the
SumWordLength
and SumFractionLength
,
or SumSlope
and SumBias
properties
respectively.
Product data type properties
The slope of the product of two fi
objects is related to
the ProductSlopeAdjustmentFactor
and
ProductFixedExponent
properties by
$$ProductSlope=ProductSlopeAdjustmentFactor\times {2}^{ProductFixedExponent}$$
If any of these properties are updated, the others are modified accordingly.
In a FullPrecision
multiply, the resulting word length and
fraction length are represented by
$$\begin{array}{l}{W}_{p}={W}_{a}+{W}_{b}\\ {F}_{p}={F}_{a}+{F}_{b}\end{array}$$
When the ProductMode
is KeepLSB
the word
length and fraction length are determined by
$$\begin{array}{l}{W}_{p}=\text{specifiedinthe}\text{ProductWordLength}\text{property}\\ {F}_{p}={F}_{a}+{F}_{b}\end{array}$$
When the ProductMode
is KeepMSB
the word
length and fraction length are
$$\begin{array}{l}{W}_{p}=\text{specifiedinthe}\text{ProductWordLength}\text{property}\\ {F}_{p}={W}_{p}\text{integerlength}\end{array}$$
where
$$\text{integerlength}=({W}_{a}+{W}_{b})({F}_{a}+{F}_{b})$$
When the ProductMode
is set to
SpecifyPrecision
, you specify both the word and fraction
length or slope and bias of the product data type with the
ProductWordLength
and
ProductFractionLength
, or ProductSlope
and ProductBias
properties respectively.
For more information about how certain functions use the
fimath
properties, see
Setting fimath Object Properties
Setting fimath Properties at Object Creation
You can set properties of fimath
objects at the time of
object creation by including properties after the arguments of the
fimath
constructor function.
For example, to set the overflow action to Saturate
and the
rounding method to Convergent
,
F = fimath('OverflowAction','Saturate','RoundingMethod','Convergent')
F = RoundingMethod: Convergent OverflowAction: Saturate ProductMode: FullPrecision SumMode: FullPrecision
In addition to creating a fimath
object at the command
line, you can also set fimath
properties using the
Insert fimath Constructor dialog box. For an example of
this approach, see Building fimath Object Constructors in a GUI.
Using Direct Property Referencing with fimath
You can reference directly into a property for setting or retrieving
fimath
object property values using MATLAB^{®} structurelike referencing. You do so by using a period to index
into a property by name.
For example, to get the RoundingMethod
of
F
,
F.RoundingMethod
ans = 'Convergent'
To set the OverflowAction
of F
,
F.OverflowAction = 'Wrap'
F = RoundingMethod: Convergent OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision