function y_quantized = quantizeByScale(y, scale)
    index=y;
    for i = 1:length(y)
        [~, tmp]=min(abs(scale-y(i)));
        index(i)=tmp;
    end
    y_quantized = scale(index)';
end