uencode

Quantize real matrix elements to integer values.

Syntax

q = uencode(u, n)

q = uencode(u, n, v)

q = uencode(u, n, v, sgn)

Inputs

u
The matrix to encode.
Type: double | complex
Dimension: matrix
n
The quantization exponent, specifying 2^n levels.
The valid range is [2,32]
Type: integer
Dimension: scalar
v
The upper limit of the interval to quantize, [-v,v]. Values outside of this range are restricted to the nearest bound.
(default: 1)
Type: double
Dimension: scalar
sgn
A flag to specify whether the output is 'signed' or 'unsigned'. The unsigned output range is [0, 2^n-1]. The signed output range is [-2^(n-1),2^(n-1)-1].
(default: 'unsigned')
Type: string

Outputs

q
The number of quantization units for each element.

Example

Unsigned example:
x = [-64,-49,-25,-16,-9,9,16,25,49,64];
q = uencode(x,6,60)
q = [Matrix] 1 x 10
0  5  18  23  27  36  40  45  58  63
Signed example:
x = [-64,-49,-25,-16,-9,9,16,25,49,64];
q = uencode(x,6,60,'signed')
q = [Matrix] 1 x 10
-32  -27  -14  -9  -5  4  8  13  26  31

Comments

If all(u) > 0 then the 'signed' option is likely an incorrect choice if decode will be later used to recover the original signal.