| Simulink® Fixed Point™ | ![]() |
autofixexp
The autofixexp script automatically changes the scaling for model objects that specify fixed-point data types. However, if an object's Lock output scaling against changes by the autoscaling tool parameter is selected, the script refrains from scaling that object.
This script collects range data for model objects, either from design minimum and maximum values that objects specify explicitly, or from logged minimum and maximum values that occur during simulation. Based on these values, the tool changes the scaling of fixed-point data types in a model so as to maximize precision and cover the range.
You can specify design minimum and maximum values for model objects using parameters typically titled Output minimum and Output maximum. See Blocks That Allow Signal Range Specification for a list of Simulink blocks that permit you to specify these values. In the autoscaling procedure that the autofixexp script executes, design minimum and maximum values take precedence over the simulation range.
If you intend to scale fixed-point data types using simulation minimum and maximum values, the script yields meaningful results when exercising the full range of values over which your design is meant to run. Therefore, the simulation you run prior to using autofixexp must simulate your design over its full intended operating range. It is especially important that you use simulation inputs with appropriate speed and amplitude profiles for dynamic systems. The response of a linear dynamic system is frequency dependent. For example, a bandpass filter will show almost no response to very slow and very fast sinusoid inputs, whereas the signal of a sinusoid input with a frequency in the passband will be passed or even significantly amplified. The response of nonlinear dynamic systems can have complicated dependence on both the signal speed and amplitude.
It is often good engineering practice to add a safety margin. The autofixexp script can set the binary points so as to cover an even larger range, thereby reducing the chance of an overflow occurring. However, increased range results in reduced precision, so the safety margin that you choose must be limited. To specify a safety margin:
Open the Fixed-Point Tool (see Opening the Fixed-Point Tool).
In the Dialog pane, enter a value for the Percent safety margin parameter. The default value is 0.
The Percent safety margin parameter allows you to specify a range that differs from that defined by the design or simulation range. For example, a value of 55 specifies that a range at least 55 percent larger is desired. A value of -15 specifies that a range up to 15 percent smaller is acceptable.
You should be aware that the scaling is not exact for the binary-point-only case because the range is given (approximately) by a power of two. The lower limit is exact, but the upper limit is always one bit below a power of two. For example, if the maximum value is 5 and the minimum value is -0.5, then any Percent safety margin value from -20 to slightly under 60 would produce the same binary point because these limits are less than a factor of two from each other. The binary point selected will produce a range from -8 to +8 (minus a bit).
Click Apply to save your change.
Note If you already know the simulation range you need to cover, you can use an alternate autoscaling technique described in the fixptbestprec reference page in the Simulink Reference. |
![]() | Functions — Alphabetical List | fixpt_instrument_purge | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |