MATLAB: How to find the precision length used by Simulink for representing a fixed-point block parameter

fixedfixed-pointfixedpointpointsimulink

Consider the attached model. (Note that the model contains Signal Processing Blockset source block).
The Gain parameter of the gain block is set to "Inherit via internal rule" as its Fixed-Point setting.
If the gain of the Gain block is given as 120.5, I want to be able to know how many bits are used to represent the fraction part of the gain parameter.

Best Answer

The ability to display the parameter data type is not available in Simulink.
To workaround this issue, please refer to following solution:
The parameter precision length of the Gain block depends on the precision length of the input when specified as "Inherit via internal rule" .
In order to find the precision length used by Simulink, perform the following actions:
1. In the gain's block "Signal Data Types" pane, set "Output data type mode" to be "Inherit via internal rule".
2. In the model, go to "Format -> Port/Signal Displays" menu and click "port data types" option.
3. Update the model by hitting CTRL+D
You can find the input and output data types of the Gain block on the respective signal lines. If you subtract the input data size from output data size, you will get the precision length used by Simulink to represent the Gain parameter.
In the case of the attached model, Input data type is of word length 16 and fraction length of 10.
Output data type is of word length 32 and fraction length of 18.
You can calculate the parameter's fraction length by subtracting input fraction length from output fraction length i.e. 18 -10 = 8.
Essentially when you chose the gain of the Gain block to be 120.5, the number of bits required to represent 120 is 7. one bit is used as sign bit. Hence the number of bits used to represent the non-fraction part is 8. The rest of bits are used for precision by Simulink. In this example, the input data type is 16-bit. If you take 8 bits to represent the non-fraction part, you are left with 8 more bits to be used for precision.