Skip to Main Content Skip to Search
Product Documentation

Using fipref Objects to Set Data Type Override Preferences

Overriding the Data Type of fi Objects

Use the fipref DataTypeOverride property to override fi objects with singles, doubles, or scaled doubles. Data type override only occurs when the fi constructor function is called. Objects that are created while data type override is on have the overridden data type. They maintain that data type when data type override is later turned off. To obtain an object with a data type that is not the override data type, you must create an object when data type override is off:

p = fipref('DataTypeOverride', 'TrueDoubles')
 
p =
 
         NumberDisplay: 'RealWorldValue'
    NumericTypeDisplay: 'full'
         FimathDisplay: 'full'
           LoggingMode: 'Off'
      DataTypeOverride: 'TrueDoubles'

a = fi(pi)
 
a =
 
    3.1416

          DataTypeMode: Double

p = fipref('DataTypeOverride', 'ForceOff')
 
p =
 
         NumberDisplay: 'RealWorldValue'
    NumericTypeDisplay: 'full'
         FimathDisplay: 'full'
           LoggingMode: 'Off'
      DataTypeOverride: 'ForceOff'

a
 
a =
 
    3.1416

          DataTypeMode: Double

b = fi(pi)
 
b =
 
    3.1416

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

Using Data Type Override to Help Set Fixed-Point Scaling

Choosing the scaling for the fixed-point variables in your algorithms can be difficult. In Fixed-Point Toolbox software, you can use a combination of data type override and min/max logging to help you discover the numerical ranges that your fixed-point data types need to cover. These ranges dictate the appropriate scalings for your fixed-point data types. In general, the procedure is

  1. Implement your algorithm using fixed-point fi objects, using initial "best guesses" for word lengths and scalings.

  2. Set the fipref DataTypeOverride property to ScaledDoubles, TrueSingles, or TrueDoubles.

  3. Set the fipref LoggingMode property to on.

  4. Use the maxlog and minlog functions to log the maximum and minimum values achieved by the variables in your algorithm in floating-point mode.

  5. Set the fipref DataTypeOverride property to ForceOff.

  6. Use the information obtained in step 4 to set the fixed-point scaling for each variable in your algorithm such that the full numerical range of each variable is representable by its data type and scaling.

A detailed example of this process is shown in the Fixed-Point Toolbox Fixed-Point Data Type Override, Min/Max Logging, and Scaling demo.

  


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