How can I create and access a "dsp.FIRInterpolator" object with quantized coefficients in MATLAB R2025b?

I am designing filters using the "FilterBuilder" tool in MATLAB R2025b. I can see the quantized coefficients in the "Filter Visualization Tool"; "filterBuilder" allows me to easily see the effects of quantization in order to explore word size to get the best FIR (Finite Impulse Response).
However, there does not seem to be a way to directly access the quantized coefficients for "dsp.FIR*" system objects once that design is complete. The "dsp.FIRInterpolator" object that is created in the workspace only has the full double precision coefficients in the "Numerator" property.
How can I create a "dsp.FIRInterpolator" object with quantized coefficients and access them for further analysis?

 Accepted Answer

The "dsp.FIRInterpolator" object already has and uses quantized coefficients internally when operating in fixed‑point mode, which is engaged by fixed‑point inputs. The "Numerator" property of any "dsp.FIR*" object will typically always store the full‑precision reference filter (typically double or single), not the quantized one. As of MATLAB R2025b, customizing and extracting the quantized coefficients has to be done via command line workflows.
  1. To build a filter that operates with quantized coefficients:You can control the coefficient quantization of a "dsp.FIRInterpolator" object by explicitly setting the data type (word length and fraction length). The object will then apply this quantization internally when it operates in fixed‑point mode. An example is shown below: 
    >> filter_object = dsp.FIRInterpolator(5);
    >> filter_object.CoefficientsDataType = "Custom";
    >> filter_object.CustomCoefficientsDataType = numerictype([],30,28);
    It's important to note that this does not change "filter_object.Numerator" - that remains the full‑precision reference filter as mentioned before. Quantization applies only to the fixed‑point realization, not to the stored coefficients themselves.
    Additionally, there is currently no explicit way to preset the object to do fixed-point execution. Fixed‑point execution is typically engaged by locking the object via a fixed‑point input such as: 
    y = filter_object(fi(u, 1, 16, 15))
  2. To programmatically access the quantized coefficients of a filter:For analysis and coefficient extraction, fixed‑point arithmetic can be explicitly requested on each analysis call if the object is unlocked. Locked objects apply the locked arithmetic automatically.
    For example, you can extract the frequency response of quantized coefficients by using the following line:
    >> freqz(filter_object, Arithmetic="fixed");
    You can then extract the quantized coefficients:
    >> [bq, aq] = tf(filter_object, Arithmetic="fixed");
    Note that "bq" and "aq" are double precision type - but quantized. For comparison, the full‑precision reference coefficients can be accessed with:
    >> [bd, ad] = tf(filter_object, Arithmetic="double");
    You can observe the effect of coefficient quantization via a calculation such as:
    norm(bd - bq)

More Answers (0)

Products

Release

R2025b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!