This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

quantizenumeric

Quantize numeric data

Syntax

y = quantizenumeric(x, s, w, f, r, o)
y = quantizenumeric(x, s, w, f, r)

Description

y = quantizenumeric(x, s, w, f, r, o) quantizes the value specified in x based on the numeric type information specified in s, w, f, r, and o.

example

y = quantizenumeric(x, s, w, f, r) quantizes the value specified in x using the numeric type information specified in s, w, f, and r.

Examples

collapse all

Quantize the value of pi using specified numeric type properties.

x = pi;
y = quantizenumeric(x,1,16,13,'ceil')
y = 3.1416

Specify a different rounding method. Observe how it affects the quantized value.

x = pi;
y = quantizenumeric(x,1,16,13,'fix')
y = 3.1415

Input Arguments

collapse all

The value to quantize, specified as a scalar, vector, matrix or multidimensional array.

Data Types: double

The signedness of the quantized value, specified as either 0 (unsigned) or 1 (signed).

Data Types: double

The word length of the quantized value, specified as a scalar integer.

Data Types: double

The fraction length of the quantized value, specified as a scalar integer.

Data Types: double

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

Overflow action to use for quantization, specified as either 'saturate' or 'wrap'. When no overflow action is specified, quantize numeric uses saturate.

Example:

Data Types: char

Output Arguments

collapse all

The quantized output value. y always has the same dimensions as x, and is always a double.

Introduced in R2016a