N = 3; %
quantization levels
fprintf('quant. levels = %d\n',N);
Ns = 10000;
y = zeros(Ns,1);
t = 1:Ns;
M = 1000;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MODIFY THIS PART
%%%%%%%%%%%%%%%%%%%
y(500:500+M1) = ones(M,1);
y(3000:3000+M1) = 0.6*ones(M,1);
y(5000:5000+M1) = 0.3*ones(M,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[partition,codebook] = lloyds(y,N);
[indx,quant,distor] = quantiz(y,partition,codebook);
figure(1)
plot(t,y,t,quant,'');
maxquant = max(quant);
minquant = min(quant);
codebook
fprintf('max level = %d\n',maxquant);
fprintf('min level = %d\n',minquant);
