Quantize fixedpoint numbers
q = fixed.Quantizer
q = fixed.Quantizer(nt,rm,oa)
q = fixed.Quantizer(s,wl,fl,rm,oa)
q = fixed.Quantizer(Name,Value)
creates
a quantizer q
= fixed.Quantizerq
that quantizes fixedpoint (fi
)
numbers using default fixedpoint settings.
uses
the q
= fixed.Quantizer(nt,rm,oa)numerictype
(nt
) object
information and the RoundingMethod
(rm
)
and OverflowAction
(oa
)
properties.
The numerictype
, rounding method, and overflow
action apply only during the quantization. The resulting, quantized q
does
not have any fimath attached to it.
uses
the q
= fixed.Quantizer(s,wl,fl,rm,oa)Signed
(s
), WordLength
(wl
), FractionLength
(fl
), RoundingMethod
(rm
),
and OverflowAction
(oa
)
properties.
creates
a quantizer with the property options specified by one or more q
= fixed.Quantizer(Name,Value)Name,Value
pair
arguments. You separate pairs of Name,Value
arguments
with commas. Name
is the argument name, and Value
is
the corresponding value. Name
must appear inside
single quotes (''
). You can specify several namevalue
pair arguments in any order as Name1,Value1,…,NameN,ValueN
.

Binarypoint, scaled numerictype object or slopebias scaled,
fixedpoint numerictype object. If your 

Rounding method to apply to the output data. Valid rounding
methods are: Default: 

Overflow action to take in case of data overflow. Valid overflow
actions are Default: 

Logical value, Default: 

Word length (number of bits) of the output data. The associated
property name is Default: 

Fraction length of the output data. The associated property
name is Default: 
Specify optional
commaseparated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.

The bias is part of the numerical representation used to interpret a fixedpoint number. Along with the slope, the bias forms the scaling of the number. Default: 0 

Fixedpoint exponent associated with the object. The exponent is part of the numerical representation used to express a fixedpoint number. The exponent of a fixedpoint number is equal to the negative
of the fraction length. Default: 15 

Fraction length of the stored integer value of the object, in bits. The fraction length can be any integer value. This property automatically defaults to the best precision possible
based on the value of the word length and the realworld value of
the Default: 15 

Action to take in case of data overflow. Valid overflow actions
are Default: 

Rounding method to apply to the output data. Valid rounding
methods are: Default: 

Whether the object is signed. The possible values of this property are:
NoteAlthough the Default: 

Whether the object is signed, unsigned, or has an unspecified sign. The possible values of this property are:
Default: 

Slope associated with the object. The slope is part of the numerical representation used to express a fixedpoint number. Along with the bias, the slope forms the scaling of a fixedpoint number. Default: 2^15 

Slope adjustment associated with the object. The slope adjustment is equivalent to the fractional slope of a fixedpoint number. The fractional slope is part of the numerical representation used to express a fixedpoint number.
Default: 1 

Word length of the stored integer value of the object, in bits. The word length can be any positive integer value. Default: 16 

Quantizer that quantizes fi input numbers 
Use fixed.Quantizer
to reduce the word
length that results from adding two fixedpoint numbers.
q = fixed.Quantizer; x1 = fi(0.1,1,16,15); x2 = fi(0.8,1,16,15); y = quantize(q,x1+x2);
Use fixed.Quantizer
object to change a
binary point scaled fixedpoint fi to a slopebias scaled fixedpoint
fi
qsb = fixed.Quantizer(numerictype(1,7,1.6,0.2),... 'Round','Saturate'); ysb = quantize(qsb,fi(pi,1,16,13));
Use y = quantize(q,x)
to quantize
input array x
using the fixedpoint settings of
quantizer q
. x
can be any
fixedpoint number fi, except a Boolean value. If x
is
a scaled double, the x
and y
data
will be the same, but y
will have fixedpoint settings.
If x
is a double or single then y
= x
.
This functionality lets you share the same code for both floatingpoint
data types and fi objects when quantizers are present.
Use n = numerictype(q)
to get a
numerictype for the current settings of quantizer q
.
Use clone(q)
to create a quantizer
object with the same property values as q
.
If you use a fixed.quantizer
in
code generation, note that it is a handle object and must be declared
as persistent.