Problem 263. Nonuniform quantizer as a piecewise constant function
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
Matthew Eicholtz
on 22 Aug 2015
I think the first line should read x<-3, not x<3.
Steve Eddins
on 24 Aug 2015
Fixed. Thanks.
Solution Comments
Show commentsProblem Recent Solvers55
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
50470 Solvers
-
Count from 0 to N^M in base N.
236 Solvers
-
I've got the power! (Inspired by Project Euler problem 29)
131 Solvers
-
The Answer to Life, the Universe, and Everything
545 Solvers
-
Area of an equilateral triangle
6413 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!