function y = q(x,c,v)
%
% Compute quantizer function
%
%   q(x) = c_i if x in V_i
%
% where V_1   = (-inf,v(1)]
%       V_2   = (v(1),v(2)]
%       ...
%       V_N-1 = (v(N-2),v(N-1)]
%       V_N   = (v(N-1),inf)
%
N = length(c);
vv = zeros(size(c));	% Allow c to be N x 1 or 1 x N.
vv(1:N-1) = v;
vv(N) = inf;
i = min(find(x <= vv));
y = c(i);
