Cody

# Problem 263. Nonuniform quantizer as a piecewise constant function

Solution 1424200

Submitted on 25 Jan 2018
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   Fail
assert(isequal(nonuniformQuantizer(-23), -3.5));

Assertion failed.

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   Fail
assert(isequal(nonuniformQuantizer(-Inf), -3.5));

Assertion failed.

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

7   Fail
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)));

Assertion failed.

8   Fail
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')));

Assertion failed.

9   Fail
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))));

Assertion failed.

10   Fail
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))));

Assertion failed.