Skip to Main Content Skip to Search
Product Documentation

fi Object Properties

Data Properties

The data properties of a fi object are always writable.

To learn more about these properties, see fi Object Properties in the Fixed-Point Toolbox Reference.

fimath Properties

In general, the fimath properties associated with fi objects depend on how you create the fi object:

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.

To learn more about these properties, see the fimath Object Properties in the Fixed-Point Toolbox Reference.

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:

For further details on these properties, see the Property Reference.

There are two ways to specify properties for fi objects in Fixed-Point Toolbox software. Refer to the following sections:

Setting fi Object Properties

You can set fi object properties in two ways:

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 mode to wrap and the rounding mode to convergent,

a = fi(pi, 'OverflowMode', 'wrap', 'RoundMode', 'convergent') 

a =
 
    3.1416


          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

             RoundMode: convergent
          OverflowMode: wrap
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128

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 OverflowMode of a,

a.OverflowMode = 'wrap' 

a =
 
    3.1416


          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

             RoundMode: convergent
          OverflowMode: wrap
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128

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, 'RoundMode', 'Floor')

b =
    3.1415

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

             RoundMode: floor
          OverflowMode: saturate
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128

b.fimath = []

b =
    3.1415

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

isfimathlocal(b)

ans =
     0
  


Free Early Verification Kit

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-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS