| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fixed-Point Toolbox |
| Contents | Index |
| Learn more about Fixed-Point Toolbox |
a = ufi
a = ufi(v)
a = ufi(v,w)
a = ufi(v,w,f)
a = ufi(v,w,slope,bias)
a = ufi(v,w,slopeadjustmentfactor,fixedexponent,bias)
You can use the ufi constructor function in the following ways:
a = ufi is the default constructor and returns an unsigned fi object with no value, 16-bit word length, and 15-bit fraction length.
a = ufi(v) returns an unsigned fixed-point object with value v, 16-bit word length, and best-precision fraction length.
a = ufi(v,w) returns an unsigned fixed-point object with value v, word length w, and best-precision fraction length.
a = ufi(v,w,f) returns an unsigned fixed-point object with value v, word length w, and fraction length f.
a = ufi(v,w,slope,bias) returns an unsigned fixed-point object with value v, word length w, slope, and bias.
a = ufi(v,w,slopeadjustmentfactor,fixedexponent,bias) returns an unsigned fixed-point object with value v, word length w, slopeadjustmentfactor, fixedexponent, and bias.
fi objects created by the ufi constructor function have the following general types of properties:
These properties are described in detail in fi Object Properties in the Properties Reference.
Note fi objects created by the ufi constructor function are always associated with the global fimath. See Working with the Global fimath in the Fixed-Point Toolbox User's Guide for more information. |
The data properties of a fi object are always writable.
bin — Stored integer value of a fi object in binary
data — Numerical real-world value of a fi object
dec — Stored integer value of a fi object in decimal
double — Real-world value of a fi object, stored as a MATLAB double
hex — Stored integer value of a fi object in hexadecimal
int — Stored integer value of a fi object, stored in a built-in MATLAB integer data type. You can also use int8, int16, int32, int64, uint8, uint16, uint32, and uint64 to get the stored integer value of a fi object in these formats
oct — Stored integer value of a fi object in octal
These properties are described in detail in fi Object Properties.
When you create a fi object with the ufi constructor function, no fimath object is explicitly attached to the fi object. Instead, the fi object is associated with the global fimath. When a fi object is associated with the global fimath, you can change its fimath properties by reconfiguring the global fimath, or by assigning the fi object its own fimath object. For more information, see Working with the Global fimath in the Fixed-Point Toolbox User's Guide.
fimath — fixed-point math object
The following fimath properties are always writable and, by transitivity, are also properties of a fi object.
CastBeforeSum — Whether both operands are cast to the sum data type before addition
MaxProductWordLength — Maximum allowable word length for the product data type
MaxSumWordLength — Maximum allowable word length for the sum data type
OverflowMode — Overflow mode
ProductBias — Bias of the product data type
ProductFixedExponent — Fixed exponent of the product data type
ProductFractionLength — Fraction length, in bits, of the product data type
ProductMode — Defines how the product data type is determined
ProductSlope — Slope of the product data type
ProductSlopeAdjustmentFactor — Slope adjustment factor of the product data type
ProductWordLength — Word length, in bits, of the product data type
RoundMode — Rounding mode
SumBias — Bias of the sum data type
SumFixedExponent — Fixed exponent of the sum data type
SumFractionLength — Fraction length, in bits, of the sum data type
SumMode — Defines how the sum data type is determined
SumSlope — Slope of the sum data type
SumSlopeAdjustmentFactor — Slope adjustment factor of the sum data type
SumWordLength — The word length, in bits, of the sum data type
These properties are described in detail in fimath Object 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 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 a fi object
DataType — Data type category associated with a fi object
DataTypeMode — Data type and scaling mode of a fi object
FixedExponent — Fixed-point exponent associated with a fi object
SlopeAdjustmentFactor — Slope adjustment associated with a fi object
FractionLength — Fraction length of the stored integer value of a fi object in bits
Scaling — Fixed-point scaling mode of a fi object
Signed — Whether a fi object is signed or unsigned
Signedness — Whether a fi object is signed or unsigned
Slope — Slope associated with a fi object
WordLength — Word length of the stored integer value of a fi object in bits
For further details on these properties, see numerictype Object Properties.
Note For information about the display format of fi objects, refer to Display Settings. For examples of casting, see Casting fi Objects. |
For example, the following creates an unsigned fi object with a value of pi, a word length of 8 bits, and a fraction length of 3 bits:
a = ufi(pi,8,3)
a =
3.1250
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 8
FractionLength: 3The fimath properties associated with a come from the global fimath. When a fi object does not have its own explicitly attached fimath object, it associates itself with the global fimath, and no fimath object properties are displayed in its output. To determine whether a fi object has an explicitly attached fimath object or if it is associated with the global fimath, use the isfimathlocal function.
isfimathlocal(a)
ans =
0A returned value of 0 means the fi object is associated with the global fimath and does not have its own explicitly attached fimath object. When the isfimathlocal function returns a 1, the fi object has its own explicitly attached fimath object.
The value v can also be an array:
a = ufi((magic(3)/10),16,12)
a =
0.8000 0.1001 0.6001
0.3000 0.5000 0.7000
0.3999 0.8999 0.2000
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 16
FractionLength: 12
>> If you omit the argument f, it is set automatically to the best precision possible:
a = ufi(pi,8)
a =
3.1406
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 8
FractionLength: 6If you omit w and f, they are set automatically to 16 bits and the best precision possible, respectively:
a = ufi(pi)
a =
3.1416
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 16
FractionLength: 14fi, fimath, fipref, isfimathlocal, numerictype, quantizer, sfi
![]() | triu | uint8 | ![]() |

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |