fi Object Properties
Data Properties
The data properties of a fi
object are always writable.
bin
— Stored integer value of afi
object in binarydata
— Numerical real-world value of afi
objectdec
— Stored integer value of afi
object in decimaldouble
— Real-world value of afi
object, stored as a MATLAB®double
data typehex
— Stored integer value of afi
object in hexadecimalint
— Stored integer value of afi
object, stored in a built-in MATLAB integer data typeoct
— Stored integer value of afi
object in octal
To learn more about these properties, see fi Object Properties in the Fixed-Point Designer™ Reference.
fimath Properties
In general, the fimath
properties associated with
fi
objects depend on how you create the fi
object:
When you specify one or more
fimath
object properties in thefi
constructor, the resultingfi
object has a localfimath
object.When you do not specify any
fimath
object properties in thefi
constructor, the resultingfi
object has no localfimath
.
To determine whether a fi
object has a local
fimath
object, use the isfimathlocal
function.
The fimath
properties associated with fi
objects determine how fixed-point arithmetic is performed. These
fimath
properties can come from a local
fimath
object or from default fimath
property values. To learn more about fimath
objects in
fixed-point arithmetic, see fimath Rules for Fixed-Point Arithmetic.
The following fimath
properties are, by transitivity, also
properties of the fi
object. You can set these properties for
individual fi
objects. The following fimath
properties are always writable.
CastBeforeSum
— Whether both operands are cast to the sum data type before additionNote
This property is hidden when the
SumMode
is set toFullPrecision
.MaxProductWordLength
— Maximum allowable word length for the product data typeMaxSumWordLength
— Maximum allowable word length for the sum data typeOverflowAction
— Action to take on overflowProductBias
— Bias of the product data typeProductFixedExponent
— Fixed exponent of the product data typeProductFractionLength
— Fraction length, in bits, of the product data typeProductMode
— Defines how the product data type is determinedProductSlope
— Slope of the product data typeProductSlopeAdjustmentFactor
— Slope adjustment factor of the product data typeProductWordLength
— Word length, in bits, of the product data typeRoundingMethod
— Rounding methodSumBias
— Bias of the sum data typeSumFixedExponent
— Fixed exponent of the sum data typeSumFractionLength
— Fraction length, in bits, of the sum data typeSumMode
— Defines how the sum data type is determinedSumSlope
— Slope of the sum data typeSumSlopeAdjustmentFactor
— Slope adjustment factor of the sum data typeSumWordLength
— The word length, in bits, of the sum data type
For more information, see fimath Object Properties.
numerictype Properties
When you create a fi
object, a numerictype
object is also automatically created as a property of the fi
object:
numerictype
— Object containing all the data type
information of a fi
object, Simulink® signal, or model parameter
The following numerictype
properties are, by transitivity, also
properties of a fi
object. The following properties of the
numerictype
object become read only after you create the
fi
object. However, you can create a copy of a
fi
object with new values specified for the
numerictype
properties:
Bias
— Bias of afi
objectDataType
— Data type category associated with afi
objectDataTypeMode
— Data type and scaling mode of afi
objectFixedExponent
— Fixed-point exponent associated with afi
objectFractionLength
— Fraction length of the stored integer value of afi
object in bitsScaling
— Fixed-point scaling mode of afi
objectSigned
— Whether afi
object is signed or unsignedSignedness
— Whether afi
object is signed or unsignedNote
numerictype
objects can have aSignedness
ofAuto
, but allfi
objects must beSigned
orUnsigned
. If anumerictype
object withAuto
Signedness
is used to create afi
object, theSignedness
property of thefi
object automatically defaults toSigned
.Slope
— Slope associated with afi
objectSlopeAdjustmentFactor
— Slope adjustment associated with afi
objectWordLength
— Word length of the stored integer value of afi
object in bits
For more information, see numerictype Object Properties.
There are two ways to specify properties for fi
objects in
Fixed-Point Designer software. Refer to the following sections:
Setting fi Object Properties
You can set fi
object properties in two ways:
Setting the properties when you create the object
Using direct property referencing
Setting Fixed-Point Properties at Object Creation
You can set properties of fi
objects at the time of object
creation by including properties after the arguments of the
fi
constructor function. For example, to set the overflow
action to Wrap
and the rounding method to
Convergent
,
a = fi(pi,'OverflowAction','Wrap','RoundingMethod','Convergent')
a = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13 RoundingMethod: Convergent OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision
To set the stored integer value of a fi
object, use the
parameter/value pair for the 'int'
property when you create
the object. For example, create a signed fi
object with a
stored integer value of 4, 16-bit word length, and 15-bit fraction
length.
x = fi(0,1,16,15,'int',4);
Verify that the fi
object has the expected integer
setting.
x.int
ans = int16 4
Using Direct Property Referencing with fi
You can reference directly into a property for setting or retrieving
fi
object property values using MATLAB structure-like referencing. You do so by using a period to index
into a property by name.
For example, to get the WordLength
of
a
,
a.WordLength
ans = 16
To set the OverflowAction
of a
,
a.OverflowAction = 'Wrap'
a = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13 RoundingMethod: Convergent OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision
If you have a fi
object b
with a local
fimath
object, you can remove the local
fimath
object and force b
to use
default fimath
values:
b = fi(pi,1,'RoundingMethod','Floor')
b = 3.1415 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13 RoundingMethod: Floor OverflowAction: Saturate ProductMode: FullPrecision SumMode: FullPrecision
b.fimath = []
b = 3.1415 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
isfimathlocal(b)
ans = logical 0