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

    %% Set the Bit at a Certain Position with Fixed Point Index  

% Copyright 2015 The MathWorks, Inc.


%% 
% Consider the following fixed-point scalar with a value of 5. 
a = fi(5,0,4,0);
disp(bin(a))  

%% 
% Set the bit at position |fi(2)| to |1|. 
c = bitset(a,fi(2),1);
disp(bin(c))