Documentation Center |
Quantize fixed-point numbers
q = fixed.Quantizer
q = fixed.Quantizer(nt,rm,oa)
q = fixed.Quantizer(s,wl,fl,rm,oa)
q = fixed.Quantizer(Name,Value)
q = fixed.Quantizer creates a quantizer q that quantizes fixed-point (fi) numbers using default fixed-point settings.
q = fixed.Quantizer(nt,rm,oa) uses the 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.
q = fixed.Quantizer(s,wl,fl,rm,oa) uses the Signed (s), WordLength (wl), FractionLength (fl), RoundingMethod (rm), and OverflowAction (oa) properties.
q = fixed.Quantizer(Name,Value) creates a quantizer with the property options specified by one or more 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 name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN.
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
'Bias' |
The bias is part of the numerical representation used to interpret a fixed-point number. Along with the slope, the bias forms the scaling of the number. Default: 0 | |
'FixedExponent' |
Fixed-point exponent associated with the object. The exponent is part of the numerical representation used to express a fixed-point number. The exponent of a fixed-point number is equal to the negative of the fraction length. FixedExponent must be an integer. Default: -15 | |
'FractionLength' |
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 real-world value of the fi object. Default: 15 | |
'OverflowAction' |
Action to take in case of data overflow. Valid overflow actions are Saturate and Wrap. . Default: Wrap | |
'RoundingMethod' |
Rounding method to apply to the output data. Valid rounding methods are: Ceiling, Convergent, Floor, Nearest, Round, and Zero. Default: Floor | |
'Scaling' |
Scaling mode of the object. The possible values of this property are:
Default: BinaryPoint | |
'Signed' |
Whether the object is signed. The possible values of this property are:
Default: true | |
'Signedness' |
Whether the object is signed, unsigned, or has an unspecified sign. The possible values of this property are:
Default: Signed | |
'Slope' |
Slope associated with the object. The slope is part of the numerical representation used to express a fixed-point number. Along with the bias, the slope forms the scaling of a fixed-point number. Default: 2^-15 | |
'SlopeAdjustmentFactor' |
Slope adjustment associated with the object. The slope adjustment is equivalent to the fractional slope of a fixed-point number. The fractional slope is part of the numerical representation used to express a fixed-point number. SlopeAdjustmentFactor must be greater than or equal to 1 and less than 2. Default: 1 | |
'WordLength' |
Word length of the stored integer value of the object, in bits. The word length can be any positive integer value. Default: 16 |
Use fixed.Quantizer to reduce the word length that results from adding two fixed-point 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 fixed-point fi to a slope-bias scaled fixed-point fi
qsb = fixed.Quantizer(numerictype(1,7,1.6,0.2),... 'Round','Saturate'); ysb = quantize(qsb,fi(pi,1,16,13));
fi | numerictype | quantizer