Quantize the value of pi using a signed numeric type with a word length of 16 bits, a fraction length of 13 bits, and rounding towards positive infinity.
x = pi;
y = quantizenumeric(x,1,16,13,'ceil')
y = 3.1416
Specify a different rounding method. Observe rounding towards zero affects the quantized value.
The value to quantize, specified as a scalar, vector, matrix
or multidimensional array.
Data Types: double
s — signedness 1 | 0
The signedness of the quantized value, specified as either 0 (unsigned)
or 1 (signed).
Data Types: double
w — word length scalar integer
The word length of the quantized value, specified as a scalar
integer.
Data Types: double
f — fraction length scalar integer
The fraction length of the quantized value, specified as a scalar
integer.
Data Types: double
r — Rounding method character vector
Rounding method to use for quantization, specified as one of
the following:
ceil— Round towards positive
infinity (same as 'ceiling')
ceiling— Round towards positive
infinity (same as 'ceil')
convergent— Convergent rounding
fix— Round towards zero
(same as 'zero')
floor— Round towards negative
infinity
nearest— Round towards nearest
with ties rounding towards positive infinity
round— Round towards nearest
with ties rounding up in absolute value
zero— Round towards zero
(same as 'fix')
Data Types: char
o — Overflow action saturate | wrap
Overflow action to use for quantization, specified as either 'saturate' or 'wrap'.
When no overflow action is specified, quantize numeric uses saturate.