|On this page…|
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
Choosing the scaling for the fixed-point variables in your algorithms can be difficult. In Fixed-Point Designer™ 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
Implement your algorithm using fixed-point fi objects, using initial "best guesses" for word lengths and scalings.
Set the fipref DataTypeOverride property to ScaledDoubles, TrueSingles, or TrueDoubles.
Set the fipref LoggingMode property to on.
Set the fipref DataTypeOverride property to ForceOff.
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 Designer Setting Fixed-Point Data Types Using Min/Max InstrumentationSetting Fixed-Point Data Types Using Min/Max Instrumentation example.