How do I properly quantize an n-bit fixed-point data to m-bit fixed-point data with a bias (n>m) using the FI function from the Fixed-Point Toolbox 1.3 (R14SP3)?

3 visualizaciones (últimos 30 días)
I tried to use the following command to convert a 5-bit (3-bit fraction) fixed-point data to a 2-bit (1-bit fraction) fixed-point data with a bias:
E = fi([-0.25+0.125i;0.25-0.75i;0.5+0.875i;-0.25-0.5i;-0.5-0.125i;],1,5,3)
Q = numerictype(1,2,0.5,0.25)
a = fi(E,Q)
Where E is the input 5-bit (3-bit fraction) embedded.fi fixed-point data and Q is a embedded.numerictype object specifying a to be a 2-bit (1-bit fraction) embedded.fi fixed-point data with a bias of 0.25.
The resulting output fixed-point data a is not quantized correctly.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 27 de Jun. de 2009
This enhancement has been incorporated in Release 2008a (R2008a). For previous product releases, read below for any possible workarounds:
The FI function is working as it is designed see the following example.
In the MATLAB command window:
a = fi(E,Q)
The issue is with the casting from a fixed-point data type to another fixed-point data type. MATLAB is actually processing the command in this manner:
a = fi(zeros(size(E)),Q)
a(:) = E;
The first command creates a fixed-point object with the attributes from numerictype Q and initializes all elements to be 0 (or 0.25 with the bias). The second command then converts the 5-bit fixed-point data E to the 2-bit fixed-point data a. The fixed-point conversion follows the fixed-point conversion arithmetic. It is outlined in the article attached in the resolution documents section.
To obtain the quantization that you are looking for, you should execute the following command:
b = fi(double(E),Q)
Which MATLAB processes as the following commands:
b = fi(zeros(size(E)),Q)
b(:) = double(E)

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by