function y=nckvant(x,b);
% Unifromni kvantizacija s osiguranim nultim nivoom.
%   y = nckvant(x, bits)

devijacija = std(x);
sredina = mean(x);

mini = sredina - 3 * devijacija;
raspon = 6 * devijacija;

n = 2^b;

c=-mini/raspon;

y = ((x - mini) / raspon - c) * n;

y = floor(y);

ind = find(y < -n/2);  y(ind)= -n/2;
ind = find(y > n/2-1); y(ind)= n/2-1;

y = (y / n + c) * raspon + mini;