%% Plot the sector bound for logarithmic quantizer

function PlotSectorBound(rho)

% Parameters
delta = (1-rho)/(1+rho);

u = -60:0.1:60;
y = zeros(length(u),1);

% Value after quantization
for ct = 1:length(u)
   if (u(ct) == 0)
      y(ct) = 0;
   elseif (u(ct) > 0)
      y(ct) = LogQuantPositive(u(ct),1,rho);
   else
      y(ct) = - LogQuantPositive(-u(ct),1,rho);
   end
end

% Lower and upper bound
upperBound = (1+delta)*u;
lowerBound = (1-delta)*u;

% Plot the sector bound [1-delta,1+delta] for the quantizer
figure;
plot(u,y,'r');
hold on;
plot(u,lowerBound,'b');
grid on;
hold on;
plot(u,upperBound,'b');
hold on;
plot(u,u,'g')
title('Logarithmic quantizer')
legend('quantized value','lower bound','upper bound','exact value','Location','northwest')
end

