% converter model
B = 8;  		 % bits
range = 2^(B-1) - 1;
% thresholds (ideal converter)
th = -range:range;	 % ideal thresholds
th = th - 0.0002 .* th .* th;
% th(20) = th(20)+0.7; % error
th = th + 0.05*randn(1, length(th));

fs = 1e6;
fx = 494e3 + pi;	 % try fs/10!
C  = round(500 * 2^B / (fs / fx));

t = 0:1/fs:C/fx;
x = (range+1) * sin(2*pi*fx.*t);
y = adc(x, th) - 2^(B-1);

hist(y, min(y):max(y));

dnl_inl_sin(y);
