Fixed-Point Blockset | ![]() ![]() |
Example: Constant Scaling for Best Precision
The Fixed-Point Blockset provides you with block-specific modes for scaling constant vectors and constant matrices. These scaling modes are based on radix point-only scaling and are described below:
Constant matrix and constant vector scaling are available only for generalized fixed-point data types. All other fixed-point data types use their default scaling. The available constant matrix scaling modes are shown below for the Matrix Gain block.
To understand how you might use these scaling modes, consider a 5- by- 4 matrix of doubles, M, defined as
3.3333e-005 3.3333e-006 3.3333e-007 3.3333e-008
3.3333e-004 3.3333e-005 3.3333e-006 3.3333e-007
3.3333e-003 3.3333e-004 3.3333e-005 3.3333e-006
3.3333e-002 3.3333e-003 3.3333e-004 3.3333e-005
3.3333e-001 3.3333e-002 3.3333e-003 3.3333e-004
Now suppose M is input into the Matrix Gain block, and you want to scale it using one of the constant matrix scaling modes. The results of using these modes are described below:
Note that many of the matrix elements are zero, and for the nonzero entries, the scaled values differ from the original values. This is because a double is converted to a binary word of fixed size and limited precision for each element. The larger and more precise the conversion data type, the more closely the scaled values match the original values.
The disadvantage of scaling the matrix column-wise, row-wise, or matrix-wise is reduced precision resulting from the use of a common radix point. The advantage of using a common radix point is reduced code size and possibly increased processor speed.
![]() | Example: Fixed-Point Scaling | Floating-Point Numbers | ![]() |