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

    %% Quantize Slope-Bias Scaled to Slope-Bias Scaled Data  

%% 
% Create a |numerictype| object, |ntSB|, which specifies a slope-bias data
% type. 
ntSB = numerictype('Scaling','SlopeBias', ...
      'SlopeAdjustmentFactor',1.8,'Bias',...
      1,'FixedExponent',-12);    

%% 
% Define the input. 
x_SB = fi(rand(5,3),numerictype('Scaling','SlopeBias','Bias',-0.125))  

%% 
% Use the defined |numerictype|, |ntSB|, to quantize the input, |x_SB|,
% to a slope-bias data type. 
ySB2 = quantize(x_SB,ntSB,'Ceiling','Wrap')