| 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 |
The global fimath is the set of fimath properties that fi constructors associate with, and fimath constructors return, when you do not specify any fimath properties in the constructor. If you do not specify any fimath properties in a fi object constructor, the resulting fi object associates itself with the global fimath. You can partially specify a fimath object in a fi or fimath constructor using property name/property value pairs. Doing so allows the remaining unspecified fimath properties to inherit their values from the global fimath. The factory-default setting of the global fimath has the following properties:
RoundMode: nearest
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: trueYou can use dot notation to change any fimath property of a fi object after creating the fi object. You can also use dot notation to associate an existing fi object with the global fimath. For example, the syntax a.fimath = [] removes the attached fimath object from a and associates a with the global fimath.
You can configure the global fimath using the Fixed-Point Toolbox setdefaultfimath, savedefaultfimathpref, removedefaultfimathpref, and resetdefaultfimath functions. The global fimath allows you to define your own set of fimath properties for all fi and fimath objects to use as a default. The following sections show you how to:
Create a fimath object
Set your fimath object as the global fimath for your current MATLAB session
Save your fimath object as the global fimath for all future MATLAB sessions
Reset the global fimath to the factory default for your current MATLAB session
Remove a user-configured global fimath from your MATLAB preferences and use the factory-default global fimath for all future MATLAB sessions
See the following section for information on how a fi object with an attached fimath object interacts with a fi object associated with the global fimath:
| fimath Rules for Fixed-Point Arithmetic |
You can configure the global fimath in two ways:
By using property name/property value pairs inside the setdefaultfimath function. Any property that you fail to specify a value for defaults to the value of the current global fimath.
setdefaultfimath('RoundMode', 'Floor', 'OverflowMode', 'Wrap');By selecting a variable name and using property name/property value pairs syntax to create a fimath object with the properties you want. Then, use the setdefaultfimath command to set the fimath object you created as the global fimath. For example:
Fdefault = fimath('RoundMode','Floor','OverflowMode','Wrap');
setdefaultfimath(Fdefault);From this point forward (in your current MATLAB session), fi and fimath objects use the global fimath you configured. All fi objects you create without specifying any fimath properties in the constructor associate themselves with the global fimath. You can determine if a fi object is associated with the global fimath by using the isfimathlocal function:
a = fi(pi)
a =
3.1416
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 13
isfimathlocal(a)
ans =
0
F1 = fimath
F1 =
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
If you want to use the current global fimath in future MATLAB sessions, you must save it as a preference. The savedefaultfimathpref function saves the current global fimath as a preference, and MATLAB uses that global fimath in all future sessions.
To use the current global fimath in all future MATLAB sessions, type
savedefaultfimathpref;
at the MATLAB command line. MATLAB now uses the current global fimath in all of your future MATLAB sessions.
You can reset the global fimath to the factory setting at any time by using the resetdefaultfimath function. To do so, type
resetdefaultfimath;
at the MATLAB command line.
When you reset the global fimath, all fi objects that are associated with it become associated with the factory-default fimath properties. Unless you choose to configure the global fimath again, MATLAB uses the factory-default setting of the global fimath for the remainder of your MATLAB session.
b = fi(pi)
b =
3.1416
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 13
b.fimath
ans =
RoundMode: nearest
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
F1 = fimath
F1 =
RoundMode: nearest
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: trueTo reset the global fimath to the factory default for all future MATLAB sessions, remove the user-configured global fimath from your MATLAB preferences. To do so, type
removedefaultfimathpref;
at the MATLAB command line. This command sets the global fimath back to its factory-default configuration for all future MATLAB sessions.
For information about using the global fimath with the Embedded MATLAB Function block, see the following section:
| Using fimath Objects in Embedded MATLAB Function Blocks |
![]() | Constructing fimath Objects | fimath Object Properties | ![]() |

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 |