www.gusucode.com > fixedpoint 案例源码程序 matlab代码 > fixedpoint/QuantizeBuiltinIntegertoSlopeBiasDataExample.m
%% Quantize Built-in Integer to Slope-Bias 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. xInt = int8(-16:4:16) %% % Use the defined |numerictype|, |ntSB|, to quantize the input, |xInt|, % to a slope-bias data type. ySB3 = quantize(xInt,ntSB,'Round','Saturate') %% % Show the range of the quantized output. range(ySB3) %% % The first and last values saturate because they are at the limits of he % representable range of the output type.