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

    %% Quantize an input
%% 
% Create a quantizer object, and use it to quantize input data. The quantizer object applies its properties
% to the input data to return quantized output.
%%

% Copyright 2015 The MathWorks, Inc.

q = quantizer('fixed', 'convergent', 'wrap', [3 2]);
x = (-2:eps(q)/4:2)';
y = round(q,x);
plot(x,[x,y],'.-'); 
axis square;
%%
% Applying quantizer object q to the data resulted in a staircase-shape output plot. Linear data input results in 
% output where y shows distinct quantization levels.