| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fixed-Point Toolbox |
| Contents | Index |
| Learn more about Fixed-Point Toolbox |
q = quantizer
q = quantizer('PropertyName1',PropertyValue1,...)
q = quantizer(PropertyValue1,PropertyValue2,...)
q = quantizer(struct)
q = quantizer(pn,pv)
q = quantizer creates a quantizer object with properties set to their default values.
q = quantizer('PropertyName1',PropertyValue1,...) uses property name/ property value pairs.
q = quantizer(PropertyValue1,PropertyValue2,...) creates a quantizer object with the listed property values. When two values conflict, quantizer sets the last property value in the list. Property values are unique; you can set the property names by specifying just the property values in the command.
q = quantizer(struct), where struct is a structure whose field names are property names, sets the properties named in each field name with the values contained in the structure.
q = quantizer(pn,pv) sets the named properties specified in the cell array of strings pn to the corresponding values in the cell array pv.
The quantizer object property values are listed below. These properties are described in detail in quantizer Object Properties.
| Property Name | Property Value | Description |
|---|---|---|
mode | 'double' | Double-precision mode. Override all other parameters. |
'float' | Custom-precision floating-point mode. | |
'fixed' | Signed fixed-point mode. | |
'single' | Single-precision mode. Override all other parameters. | |
'ufixed' | Unsigned fixed-point mode. | |
roundmode | 'ceil' | Round toward positive infinity. |
'convergent' | Round to nearest integer with ties rounding to nearest even integer. | |
'fix' | Round toward zero. | |
'floor' | Round toward negative infinity. | |
'nearest' | Round to nearest integer with ties rounding toward positive infinity. | |
'round' | Round to nearest integer with ties rounding to nearest integer with greater absolute value. | |
overflowmode (fixed-point only) | 'saturate' | Saturate on overflow. |
'wrap' | Wrap on overflow. | |
format | [wordlength fractionlength] | Format for fixed or ufixed mode. |
[wordlength exponentlength] | Format for float mode. |
The default property values for a quantizer object are
mode = 'fixed'; roundmode = 'floor'; overflowmode = 'saturate'; format = [16 15];
Along with the preceding properties, quantizer objects have read-only states: max, min, noverflows, nunderflows, and noperations. They can be accessed through quantizer/get or q.maxlog, q.minlog, q.noverflows, q.nunderflows, and q.noperations, but they cannot be set. They are updated during the quantizer/quantize method, and are reset by the resetlog function.
The following table lists the read-only quantizer object states:
| Property Name | Description |
|---|---|
max | Maximum value before quantizing |
min | Minimum value before quantizing |
noverflows | Number of overflows |
nunderflows | Number of underflows |
noperations | Number of data points quantized |
The following example operations are equivalent.
Setting quantizer object properties by listing property values only in the command,
q = quantizer('fixed', 'ceil', 'saturate', [5 4])
Using a structure struct to set quantizer object properties,
struct.mode = 'fixed'; struct.roundmode = 'ceil'; struct.overflowmode = 'saturate'; struct.format = [5 4]; q = quantizer(struct);
Using property name and property value cell arrays pn and pv to set quantizer object properties,
pn = {'mode', 'roundmode', 'overflowmode', 'format'};
pv = {'fixed', 'ceil', 'saturate', [5 4]};
q = quantizer(pn, pv)
Using property name/property value pairs to configure a quantizer object,
q = quantizer( 'mode', fixed','roundmode','ceil',... 'overflowmode', 'saturate', 'format', [5 4]);
assignmentquantizer, fi, fimath, fipref, numerictype, quantize, set, unitquantize, unitquantizer
![]() | quantize | quiver | ![]() |

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |