Main Content

range

Numerical range of fi or quantizer object

Description

Range of fi Object

example

y = range(a) returns a fi object with the minimum and maximum possible values of the fi object a. All possible quantized real-world values of a are in the range returned. If a is a complex number, then all possible values of real(a) and imag(a) are in the range returned.

example

[min_a,max_a] = range(a) returns the minimum and maximum values of fi object a in separate output variables.

Range of quantizer Object

example

r = range(q) returns the two-element row vector r = [min_q max_q] such that for all real x, y = quantize(q,x) returns y in the range min_q ≤ y ≤ max_q.

example

[min_q,max_q] = range(q) returns the minimum and maximum values of the range in separate output variables.

Examples

collapse all

Create a signed fi object with a value of 0, word length of 4, and fraction length of 2.

a = fi(0,true,4,2);

Find the numerical range of the fi object a and return the result in fi object y.

y = range(a)
y = 
   -2.0000    1.7500

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 4
        FractionLength: 2

Find the numerical range of the fi object a and return the result in separate output variables.

[min_a, max_a] = range(a)
min_a = 
    -2

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 4
        FractionLength: 2
max_a = 
    1.7500

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 4
        FractionLength: 2

Note that max_a = 1.75 = 2 - eps(a).

Create a quantizer object that describes a floating-point data type having a word length of 6 and an exponent length of 3. Find the numerical range of the quantizer object q.

q = quantizer('float',[6 3]);
r = range(q)
r = 1×2

   -14    14

Create a quantizer object that describes a signed fixed-point data type having a word length of 4, and fraction length of 2, saturate on overflow, and round to floor. Find the numerical range of the quantizer object q and return the result in separate output variables.

q = quantizer('fixed',[4 2],'floor');
[min_q, max_q] = range(q)
min_q = -2
max_q = 1.7500

Note that max_q = 1.75 = 2 - eps(q).

Input Arguments

collapse all

Input fi object.

Data Types: fi
Complex Number Support: Yes

Input quantizer object.

Output Arguments

collapse all

Numerical range of input fi object a, returned as a fi object. y is a two-element row vector containing the minimum and maximum possible values of fi object a.

Minimum value of input fi object a, returned as a scalar fi object.

Maximum value of input fi object a, returned as a scalar fi object.

Numerical range of quantizer object q, returned as the two-element row vector r = [min_q max_q] such that for all real x, y = quantize(q,x) returns y in the range min_q ≤ y ≤ max_q.

Minimum value of quantizer object range, returned as a scalar.

Maximum value of quantizer object range, returned as a scalar.

Algorithms

If q is a floating-point quantizer object, min_q = -realmax(q) and max_q = realmax(q).

If q is a signed fixed-point quantizer object (datamode = 'fixed'), then

min_q = −realmax(q) − eps(q) = −2w−1/2f

max_q = realmax(q) = (2w−1 − 1)/2f

where w is the word length and f is the fraction length.

If q is an unsigned fixed-point quantizer object (datamode = 'ufixed'),

a = 0

b = realmax(q) = (2w − 1)/2f

See realmax for more information.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced before R2006a