numerictype Object Properties
Data Type and Scaling Properties
All properties of a numerictype object are writable. However, the
numerictype properties of a fi object become read
only after the fi object has been created. Any
numerictype properties of a fi object that are
unspecified at the time of fi object creation are automatically set to
their default values. The properties of a numerictype object are:
| Property | Description | Valid Values |
|---|---|---|
Bias | Bias associated with the object. Along with the slope, the bias forms the scaling of a fixed-point number. |
|
DataType | Data type category |
|
DataTypeMode | Data type and scaling associated with the object |
|
FixedExponent | Fixed-point exponent associated with the object |
Note The |
FractionLength | Fraction length of the stored integer value, in bits |
Note The |
Scaling | Scaling mode of the object |
|
Signed | Whether the object is signed Note Although the |
|
Signedness | Whether the object is signed, unsigned, or has an unspecified sign |
|
Slope | Slope associated with the object Along with the bias, the slope forms the scaling of a fixed-point number. |
Note Changing one of these properties changes the other. |
SlopeAdjustmentFactor | Slope adjustment associated with the object The slope adjustment is equivalent to the fractional slope of a fixed-point number. |
Note Changing one of these properties changes the other. |
WordLength | Word length of the stored integer value, in bits |
|
These properties are described in detail in the Set fi Object Properties. To learn how to specify properties for
numerictype objects in Fixed-Point Designer™ software, refer to Set numerictype Object Properties.
How Properties are Related
Properties that affect the slope
The Slope field of the numerictype
object is related to the SlopeAdjustmentFactor and
FixedExponent properties by
The FixedExponent and FractionLength properties
are related by
If you set the SlopeAdjustmentFactor,
FixedExponent, or FractionLength property, the
Slope field is modified.
Stored integer value and real world value
In binary point scaling the numerictype
StoredIntegerValue and RealWorldValue properties are
related according to
In [Slope Bias] scaling the RealWorldValue can be represented
by
which is equivalent to
If any of these properties are updated, the others are modified accordingly.
Set numerictype Object Properties
Setting numerictype Properties at Object Creation
You can set properties of numerictype objects at the time of object
creation by including properties after the arguments of the numerictype
constructor function.
For example, to set the word length to 32 bits and the fraction length to 30 bits,
T = numerictype('WordLength',32,'FractionLength',30)
T =
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 30
In addition to creating a numerictype object at the command line,
you can also set numerictype properties using the Insert
numerictype Constructor dialog box. For an example of this approach, see
Example: Build numerictype Object Constructors in a GUI.
Use Direct Property Referencing with numerictype Objects
You can reference directly into a property for setting or retrieving
numerictype object property values using MATLAB structure-like referencing. You do this by using a period to index into a
property by name.
For example, to get the word length of T,
T.WordLength
ans = 32
To set the fraction length of T,
T.FractionLength = 31
T =
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 31