numerictype Object Properties - MATLAB & Simulink (original) (raw)
Main Content
Data Type and Scaling Properties
All properties of a numerictype
object are writable. However, thenumerictype
properties of a fi
object become read only after the fi
object has been created. Anynumerictype
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. | Any floating-point number |
DataType | Data type category | Fixed (default) — Fixed-point or integer data typeboolean — Built-in MATLAB® boolean data typedouble — Built-in MATLABdouble data typeScaledDouble — Scaled double data typesingle — Built-in MATLABsingle data type |
DataTypeMode | Data type and scaling associated with the object | Fixed-point: binary point scaling (default) — Fixed-point data type and scaling defined by the word length and fraction lengthBoolean — Built-inbooleanDouble — Built-indoubleFixed-point: slope and bias scaling — Fixed-point data type and scaling defined by the slope and biasFixed-point: unspecified scaling — Fixed-point data type with unspecified scalingScaled double: binary point scaling — Double data type with fixed-point word length and fraction length information retainedScaled double: slope and bias scaling — Double data type with fixed-point slope and bias information retainedScaled double: unspecified scaling — Double data type with unspecified fixed-point scalingSingle — Built-insingle |
FixedExponent | Fixed-point exponent associated with the object | Any integer NoteThe FixedExponent property is the negative of theFractionLength. Changing one property changes the other. |
FractionLength | Fraction length of the stored integer value, in bits | Best precision fraction length based on value of the object and the word length (default)Any integer NoteThe FractionLength property is the negative of theFixedExponent. Changing one property changes the other. |
Scaling | Scaling mode of the object | BinaryPoint (default) — Scaling for thefi object is defined by the fraction length.SlopeBias — Scaling for thefi object is defined by the slope and bias.Unspecified — A temporary setting that is only allowed at fi object creation, to allow for the automatic assignment of a binary point best-precision scaling. |
Signed | Whether the object is signedNoteAlthough the Signed property is still supported, theSignedness property always appears in thenumerictype object display. If you choose to change or set the signedness of your numerictype objects using theSigned property, MATLAB updates the corresponding value of theSignedness property. | true (default) — signedfalse — unsigned1 — signed0 — unsigned[] — auto |
Signedness | Whether the object is signed, unsigned, or has an unspecified sign | Signed (default)Unsigned Auto — unspecified sign |
Slope | Slope associated with the objectAlong with the bias, the slope forms the scaling of a fixed-point number. | Any finite floating-point number greater than zero Note slope=slope adjustment factor×2fixed exponentChanging one of these properties changes the other. |
SlopeAdjustmentFactor | Slope adjustment associated with the objectThe slope adjustment is equivalent to the fractional slope of a fixed-point number. | Any number greater than or equal to 1 and less than 2 Note slope=slope adjustment factor×2fixed exponentChanging one of these properties changes the other. |
WordLength | Word length of the stored integer value, in bits | 16 (default)Any positive integer if Signedness isUnsigned or unspecifiedAny integer greater than one if Signedness is set toSigned |
These properties are described in detail in the Set fi Object Properties. To learn how to specify properties fornumerictype
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
andFixedExponent
properties by
The FixedExponent
and FractionLength
properties are related by
If you set the SlopeAdjustmentFactor
,FixedExponent
, or FractionLength
property, theSlope 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, seeExample: Build numerictype Object Constructors in a GUI.
Use Direct Property Referencing with numerictype Objects
You can reference directly into a property for setting or retrievingnumerictype
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
,
To set the fraction length of T
,
T =
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 31