주요 콘텐츠

quantize

R2026b

Quantize interval to range of numeric data type

Description

quantizedinterval = quantize(interval,numerictype) returns the quantized range of the fixed.Interval object interval, quantized to the numeric type specified by numerictype.

example

quantizedinterval = quantize(interval,numerictype,Name=Value) specifies additional options using one or more name-value arguments.

example

Examples

collapse all

Create a fixed.Interval object and find the range of the Interval object quantized to an unsigned 8-bit integer.

interval = fixed.Interval(-200,200);
quantizedInterval = quantize(interval,'fixdt(0,8,0)')
quantizedInterval = 1×2 uint8 row vector
0	200

Because fixdt(0,8,0) is equivalent to uint8, the quantize function returns the quantized range as a uint8 row vector with the endpoints within the representable range of the numeric type.

To return the quantized row vector as a fixed-point data type, set the PreferBuiltIn property to false.

quantizedInterval = quantize(interval, 'fixdt(0,8,0)',...
 PreferBuiltIn=false)
quantizedInterval = 

     0   200

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 0

Input Arguments

collapse all

Interval to quantize, specified as a fixed.Interval object or an array of fixed.Interval objects.

Numeric data type to quantize interval to, specified as a Simulink.Numerictype object, an embedded.numerictype object, or a character vector representing a numeric data type, for example, 'single'.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: quantizedInterval = quantize(interval,'fixdt(0,8,0)',PreferBuiltIn=1,PreferStrict=1)

Whether to quantize to built-in data type when possible, specified as a numeric or logical 1 (true) or 0 (false). When this option is set to true, if the specified numerictype has an equivalent built-in integer type the software returns the built-in type.

Data Types: logical

Whether to quantize endpoints to numeric type, specified as a numeric or logical 1 (true) or 0 (false).

When this option is set to false, the end points after quantization may lie outside the original interval. When this option is set to true, endpoints are quantized to the closest representable values within the original interval regardless of whether the intervals are open or closed.

Data Types: logical

Output Arguments

collapse all

Quantized interval range, returned as an N-by-2 matrix with rows consisting of endpoints of input interal quantized to the numeric data type specified by numerictype.

Version History

Introduced in R2019b