www.gusucode.com > fixedpoint 案例源码程序 matlab代码 > fixedpoint/ModifyingGlobalfimathExample.m

    %% Modifying globalfimath
% Use the globalfimath function to set, change, and reset the global
% fimath.
%% 
% Create a fimath object and use it as the global fimath.

% Copyright 2015 The MathWorks, Inc.

G = globalfimath('RoundMode','Floor','OverflowMode','Wrap')
%% 
% Create another fimath object using the new default. 
F1 = fimath
%% 
% Create a fi object, A, associated with the global fimath. 
A = fi(pi)
%% 
% Now set the "SumMode" property of the global fimath to 
% "KeepMSB" and retain all the other property values 
% of the current global fimath.
G = globalfimath('SumMode','KeepMSB')
%% 
% Change the global fimath by directly interacting with the handle object G.
G.ProductMode = 'SpecifyPrecision'
%% 
% Reset the global fimath to the factory default by calling the reset method on G. 
% This is equivalent to using the resetglobalfimath function.
reset(G);
G