Skip to Main Content Skip to Search
Product Documentation

Quantizing Data with quantizer Objects

You construct a quantizer object to specify the quantization parameters to use when you quantize data sets. You can use the quantize function to quantize data according to a quantizer object's specifications.

Once you quantize data with a quantizer object, its state values might change.

The following example shows

  1. Construct an example data set and a quantizer object.

    format long g
    randn('state',0);
    x = randn(100,4);
    q = quantizer([16,14]);
  2. Retrieve the values of the maxlog and noverflows states.

    q.maxlog
    
    ans =
    
        -1.79769313486232e+308
    
    q.noverflows
    
    ans =
    
         0

    Note that maxlog is equal to -realmax, which indicates that the quantizer q is in a reset state.

  3. Quantize the data set according to the quantizer object's specifications.

    y = quantize(q,x);
    Warning: 15 overflows.
  4. Check the values of maxlog and noverflows.

    q.maxlog
    
    ans =
    
              1.99993896484375
    
    q.noverflows
    
    ans =
    
        15

    Note that the maximum logged value was taken after quantization, that is, q.maxlog == max(y).

  5. Reset the quantizer states and check them.

    reset(q)
    q.maxlog
    
    ans =
    
        -1.79769313486232e+308
    
    q.noverflows
    
    ans =
    
         0

  


Free Early Verification Kit

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-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS