Cody

# Problem 263. Nonuniform quantizer as a piecewise constant function

Solution 1734940

Submitted on 24 Feb 2019 by Athi
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
assert(isequal(nonuniformQuantizer(-23), -3.5));

2   Pass
assert(isequal(nonuniformQuantizer(0), 0.5));

3   Pass
assert(isequal(nonuniformQuantizer(1.1), 1.5));

4   Pass
assert(isequal(nonuniformQuantizer(2.9), 1.5));

5   Pass
assert(isequal(nonuniformQuantizer(-Inf), -3.5));

6   Pass
assert(isequal(nonuniformQuantizer(Inf), 3.5));

7   Pass
x = -4.0:0.5:4.5; y = [-3.5 -3.5 -1.5 -1.5 -1.5 ... -1.5 -0.5 -0.5 0.5 0.5 1.5 ... 1.5 1.5 1.5 3.5 3.5 3.5 3.5]; assert(isequal(y, nonuniformQuantizer(x)));

8   Pass
x = -4.0:0.5:4.5; y = [-3.5 -3.5 -1.5 -1.5 -1.5 ... -1.5 -0.5 -0.5 0.5 0.5 1.5 ... 1.5 1.5 1.5 3.5 3.5 3.5 3.5]; assert(isequal(y', nonuniformQuantizer(x')));

9   Pass
x = -4.0:0.5:4.5; y = [-3.5 -3.5 -1.5 -1.5 -1.5 ... -1.5 -0.5 -0.5 0.5 0.5 1.5 ... 1.5 1.5 1.5 3.5 3.5 3.5 3.5]; assert(isequal(reshape(y,3,6), ... nonuniformQuantizer(reshape(x,3,6))));

10   Pass
x = -4.0:0.5:4.5; y = [-3.5 -3.5 -1.5 -1.5 -1.5 ... -1.5 -0.5 -0.5 0.5 0.5 1.5 ... 1.5 1.5 1.5 3.5 3.5 3.5 3.5]; assert(isequal(reshape(y,1,6,3), ... nonuniformQuantizer(reshape(x,1,6,3))));