Suppose you want to approximate the common logarithm (base 10) over the input range [1, 10] without performing an expensive computation. You can perform this approximation using a lookup table block as described in the following procedure. (If you want to skip the procedure, you can open the model directly.)
Copy the following blocks to a Simulink® model:
One Constant block to input the signal, from the Sources library
One n-D Lookup Table block to approximate the common logarithm, from the Lookup Tables library
One Display block to display the output, from the Sinks library
Assign the table data and breakpoint data set to the n-D Lookup Table block:
In the Number of table dimensions field, enter
1
.
In the Table data field, enter [0 .301
.477 .602 .699 .778 .845 .903 .954 1]
.
In the Breakpoints 1 field, enter
[1:10]
.
Click Apply.
The dialog box looks something like this:
Double-click the Constant block to open the parameter dialog box, and change
the Constant value parameter to 5
. Click
OK to apply the changes and close the dialog
box.
Connect the blocks as follows.
Start simulation.
The following behavior applies to the n-D Lookup Table block.
Value of the Constant Block | Action by the n-D Lookup Table Block | Example of Block Behavior | |
---|---|---|---|
Input Value | Output Value | ||
Equals a breakpoint | Returns the corresponding output value | 5 | 0.699 |
Falls between breakpoints | Linearly interpolates the output value using neighboring breakpoints | 7.5 | 0.874 |
Falls outside the range of the breakpoint data set | Linearly extrapolates the output value from a pair of values at the end of the breakpoint data set | 10.5 | 1.023 |
For the n-D Lookup Table block, the default settings for
Interpolation method and Extrapolation
method are both Linear
.