The Lookup Table Optimizer optimizes the spacing of the breakpoints and the data types of the table data to reduce the memory used by a lookup table. Using the Lookup Table Optimizer and its command-line equivalent, you can:
Optimize an existing Lookup Table block.
Generate a lookup table from a Simulink® block, including a Math Function block or a subsystem.
Generate a lookup table from a function or function handle.
To optimize an existing lookup table, open the model containing the Lookup Table block.
To open the Lookup Table Optimizer, in the model menu, select Analysis > Data Type Design > Lookup Table Optimizer.
Select the type of block you want to optimize. To optimize an existing lookup table, or a Simulink block, including a Math Function block or a subsystem, select Simulink block. To generate a lookup table approximation for a function handle, select MATLAB Function Handle.
In this example, select Simulink block to optimize the Pumping Constant lookup table. Click Next.
Under Existing Block Information, enter the path to the Lookup Table block. Select the block in the model, then click Get Current Block in the Optimizer to fill in the block path automatically.
Click the Collect Current Values from Model button to update the model diagram and allow the Optimizer to automatically gather information needed for the optimization process including current output data type, and input number, data type, and value range. You can manually edit all of these fields to specify ranges and data types other than those currently specified on the block.
Specify the data type of each input to the block as a
Specify the minimum and maximum values of each input of the generated lookup table as scalars in the table.
For this example, use the current values specified on the model. Click Next.
Specify constraints to use in the optimization. Set the Output Error Tolerance that is acceptable for your design.
Absolute tolerance is defined as the absolute value of the difference between the original output value and the output value of the optimized lookup table.
Relative tolerance measures the error relative to the value at that point, specified as a non-negative.
Specify the allowed word lengths as a vector based on types that are efficient for
your intended hardware target. For example, if you want to allow the optimizer to
consider only 8, 16, and 32-bit types, specify
[8,16,32] in the
Allowed Word Lengths (Vector) field.
To specify additional properties for the optimized lookup table, click
LUT Specification. For more information on each of the
FunctionApproximation.Options. In this example, use the default values for
Specify options for the optimization, such as the max time or maximum memory usage for the generated lookup table by clicking the button.
After you set the constraints, click Optimize. When the optimization is complete, the optimizer reports the memory of the optimized lookup table. You can edit the constraints and run the optimization again to achieve further memory reduction.
Using the default settings, the Lookup Table Optimizer reduces the memory used by the Pumping Constant Lookup Table block from 1516 bytes to 942 bytes (37.86%).
Click Show Comparison Plot to view a plot of the original block output compared to the output of the new optimized lookup table.
Click Replace Original Function to generate a new lookup table using the optimized settings found by the app, and replace the original block with the new block.