step(H, data) processes
your data and allows you to visualize the dynamic range in the scope window. The
NumericTypeScope retains previously collected information about the
variable between each call to step. In order to process new data, call
reset
before calling step again.
Use the NumericTypeScope to view the dynamic range of a fi object.
Create a fi object and set the DataTypeOverride to ScaledDoubles.
a = fi(magic(10),1,8,2);
b = fi([a; 2.^(-5:4)],1,8,3);
fp = fipref;
initialDTOSetting = fp.DataTypeOverride;
fp.DataTypeOverride = 'ScaledDoubles';
Create a NumericTypeScope object. You can use the reset method to ensure that all stored information is cleared from the NumericTypeScope object h.
h = NumericTypeScope;
reset(h)
Use the step method to process your data and visualize the dynamic range of the fi object b.
step(h,b);
Closing the NumericTypeScope window does not delete the object from your workspace. Close the NumericTypeScope window and reopen it using the show function.
show(h);
The NumericTypeScope displays a log2 histogram which shows that the values appear both outside of the range and below the precision of the data type of the variable. Pause on one bar of the histogram to view the percentage of the total values that are represented by that bar.
In this case, the data type of b is numerictype(1,8,3). The numerictype(1,8,3) data type provides 5 integer bits, including the signed bit, and 3 fractional bits. Thus, this data type can represent only values between -2^4 and 2^4 - 2^-3 (from -16 to 15.8750). Given the range and precision of this data type, values greater than 2^4 fall outside the range and values less than 2^-3 fall below the precision of the data type.
The NumericTypeScope shows that values requiring bits 5, 6, and 7 are outside the range and values requiring fractional bits 4 and 5 are below precision. Given this information, you can prevent values that are outside range and below precision by changing the data type of the variable b to numerictype(0,13,5).
Given this information, you can prevent values that are outside range and below precision by changing the data type of the variable b to numerictype(0,13,5). In the NumericTypeScope, enter numerictype(0,13,5) in the Proposed Data Type box.
Return to the original data type override setting.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.