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

    %% Quantize Built-in Integer to Binary-Point Scaled Data  

%% 
% Create a |numerictype| object, |ntBP|, which specifies a signed, 8-bit
% word length, 4-bit fraction length data type. 
ntBP = numerictype(1,8,4);    

%% 
% Define the input. 
xInt = int8(-16:4:16)  

%% 
% Use the defined |numerictype|, |ntBP|, to quantize the input|xInt| to
% a binary point scaled data type. 
yBP3 = quantize(xInt,ntBP,'Zero')  

%% 
% Show the range of the quantized output. 
range(yBP3) 

%%
% The first two and last three values are wrapped because they are outside
% the representable range of the output type.