Implement a nonuniform quantizer as the following piecewise function:
y = -3.5, x < -3
y = -1.5, -3 ≤ x < -1
y = -0.5, -1 ≤ x < 0
y = 0.5, 0 ≤ x < 1
y = 1.5, 1 ≤ x < 3
y = 3.5, 3 ≤ x
Your function should act elementwise on array inputs.
For example:
nonuniformQuantizer([-4.0 0.0 2.0])
returns
[-3.5 0.5 1.5]
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers57
Suggested Problems
-
2523 Solvers
-
Find the peak 3n+1 sequence value
2565 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2829 Solvers
-
Convert hex color specification to MATLAB RGB
254 Solvers
-
Who has power to do everything in this world?
485 Solvers
More from this Author6
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I think the first line should read x<-3, not x<3.
Fixed. Thanks.