| Contents | Index |
The global fimath is the set of fimath properties that fi objects 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. If you specify one or more fimath object properties in a fi object constructor, the resulting fi object has a local fimath object. All fimath object properties that you do not specify in a fi or fimath object constructor 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
Note fi objects that are associated with the global fimath and created from a floating-point value always get constructed with a RoundMode of nearest and an OverflowMode of saturate. To construct fi objects with different RoundMode and OverflowMode properties, specify the desired RoundMode and OverflowMode properties in the fi constructor. |
If you create a fi object with a local fimath object, you can use dot notation to change the local fimath object properties. You can also use dot notation to remove a local fimath object from an existing fi object, and associate that fi object with the global fimath. For example, if the fi object a has a local fimath object, you can use the syntax a.fimath = [] to remove its local fimath object. When you do so, a becomes associated with the global fimath.
You can configure your global fimath settings using the Fixed-Point Toolbox globalfimath, saveglobalfimathpref, removeglobalfimathpref, and resetglobalfimath 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. See the following sections for more information about the Fixed-Point Toolbox global fimath functions:
For information on how fi objects with local fimath objects interact with fi objects associated with the global fimath, see the following section:
| fimath Rules for Fixed-Point Arithmetic |
You can configure the global fimath using the globalfimath function. When you provide an output argument, this function returns a handle object to the global fimath. You can then control the global fimath properties through that handle object. The following syntaxes provide you with a handle object to the global fimath:
G = globalfimath — Use this syntax when you want to get a handle object to the global fimath, but do not want to change any of the current global fimath properties. You can modify the properties of the global fimath later using dot notation on the object G. For example, the following code gets a handle object to the global fimath, and then uses that handle object to change the RoundMode of the global fimath.
G = globalfimath; G.RoundMode = 'Floor';
G = globalfimath(f) — Use this syntax when you want to configure the global fimath using an existing fimath object f. Because this syntax specifies G as an output argument, the function returns a handle object to the global fimath. You can then modify the properties of the global fimath at any time by changing the properties of G. For example,
f = fimath('RoundMode', 'Floor');
G = globalfimath(f);
G.RoundMode = 'Nearest';G = globalfimath('RoundMode', 'Floor') — Use this syntax when you want to set the properties of the global fimath using property name/property value pairs. You can specify as many property name/property value pairs as necessary. All properties that you do not specify values for inherit their values from the current global fimath. As always, you can use the handle object to modify the global fimath properties at a later time.
G = globalfimath('RoundMode','Floor','OverflowMode','Wrap');
G.OverflowMode = 'Saturate';The global fimath properties you set with the globalfimath function apply only in your current MATLAB session. To save the global fimath for use in future MATLAB sessions, use the saveglobalfimathpref function.
If you want to use the current global fimath in future MATLAB sessions, you must save it as a preference. The saveglobalfimathpref 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
saveglobalfimathpref;
at the MATLAB command line. MATLAB now uses the current global fimath in all of your future MATLAB sessions.
There are two ways to reset the global fimath to the factory default in your current MATLAB session:
Use the resetglobalfimath function. To do so, type
resetglobalfimath;
at the MATLAB command line.
Use the reset method of the global fimath. If G is a handle object to the global fimath, type
reset(G);
at the MATLAB command line.
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. For example, after resetting the global fimath to the factory default, MATLAB returns the following fi and fimath objects:
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
F1 = fimath
F1 =
RoundMode: nearest
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
To reset the global fimath to the factory default for all future MATLAB sessions, remove your global fimath from the MATLAB preferences. To do so, type
removeglobalfimathpref;
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 MATLAB Function block, see the following section:
| Using fimath Objects in 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-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |