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

    %% Get a Specified Set of Consecutive Bits from Each Element of a Matrix  

% Copyright 2015 The MathWorks, Inc.


%% 
% Begin with the following unsigned fixed-point 3-by-3 matrix. 
a = fi([2 3 4;6 8 2;3 5 1],0,4,0);
disp(bin(a))  

%% 
% Get the binary representation of a consecutive set of bits of matrix |a|.
% For each element, start at position 4 and end at position 2. 
c = bitsliceget(a,4,2);
disp(bin(c))