| 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 |
setdefaultfimath(F)
setdefaultfimath('PropertyName1',PropertyValue1,...)
setdefaultfimath(F) sets a copy of the fimath object F as the global fimath for your current MATLAB session.
setdefaultfimath('PropertyName1',PropertyValue1,...) changes the specified properties of the current global fimath to the values you specify. All properties that are not specified as inputs to the function retain the same values as the current global fimath.
For more information on working with the global fimath, see Working with the Global fimath in the Fixed-Point Toolbox User's Guide.
Setting the Global fimath Using a Workspace Variable
If you create a fi object in the MATLAB workspace and do not specify any fimath properties in the constructor, Fixed-Point Toolbox software associates it with the global fimath. To change the global fimath, you must use the setdefaultfimath command.
In this example, you create your own fimath object F and set it as the global fimath for your current MATLAB session:
F = fimath('RoundMode','Floor','OverflowMode','Wrap')
F =
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
setdefaultfimath(F);
Because all fi and fimath objects you create without specifying fimath properties in the constructor get associated with the global fimath, the fimath properties of both F1 and a match that of F.
F1 = fimath
a = fi(pi)
F1 =
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
a =
3.1416
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 13
Because a is associated with the global fimath, MATLAB does not display its fimath properties. To verify that a is associated with the global fimath, use the isfimathlocal command. To see the fimath properties associated with a, use dot notation:
isfimathlocal(a)
a.fimath
ans =
0
ans =
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: trueTo use the current global fimath in future MATLAB sessions, you must use the savedefaultfimathpref command.
Setting the Global fimath Using Property Name/Property Value Pairs
You can use the property name/property value pairs syntax to set select properties of the global fimath. For example, to change the SumMode of the global fimath to KeepMSB, do the following:
setdefaultfimath('SumMode', 'KeepMSB');fimath, removedefaultfimathpref, resetdefaultfimath, savedefaultfimathpref
![]() | set | sfi | ![]() |

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 |