www.gusucode.com > fixedpoint 案例源码程序 matlab代码 > fixedpoint/GetBitWhenInputIsScalarandIndexIsaVectorExample.m
%% Get Bit When Input Is Scalar and Index Is a Vector % Copyright 2015 The MathWorks, Inc. %% % Create a default |fi| object with a value of |pi|. a = fi(pi); disp(bin(a)) %% % The default object is signed with a word length of 16. %% % Create a vector of the positions of the bits you want to get in |a|, and % get the binary representation of those bits. bit = fi([15,3,8,2]); c = bitget(a,bit) %% % MATLAB(R) returns a vector of the bits in |a| at the positions specified % by the index vector, |bit|.