Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Example of a Logarithm Lookup Table

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.

  1. Copy the following blocks to the Simulink model window:

    • A Constant block to input the signal, from the Sources library

    • A Lookup Table (n-D) block to approximate the common logarithm, from the Lookup Tables library

    • A Display block to display the output, from the Sinks library

  2. Assign the table data and breakpoint data set to the Lookup Table (n-D) block:

    • In the Number of table dimensions field, enter 1.

    • In the Table field, enter [0 .301 .477 .602 .698 .778 .845 .903 .954 1].

      Alternatively, you can enter the MATLAB expression log10(1:10) in this field, which evaluates to the equivalent vector of output values.

    • In the BP 1 field, enter [1:10].

    • Click Apply.

    The dialog box looks something like this:

  3. Click the Algorithm tab in the Lookup Table (n-D) block dialog box.

    By default, the Interpolation method and Extrapolation method are both Linear.

    Click OK to close the dialog box.

  4. 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.

  5. Connect the blocks as follows.

  6. In the model window, select Simulation > Start to run the simulation.

    The following behavior applies to the Lookup Table (n-D) block.

    Value of the Constant BlockAction by the Lookup Table (n-D) BlockExample of Block Behavior
    Input ValueOutput Value
    Equals a breakpointReturns the corresponding output value50.698
    Falls between breakpointsLinearly interpolates the output value using neighboring breakpoints7.50.874
    Falls outside the range of the breakpoint data setLinearly extrapolates the output value from a pair of values at the end of the breakpoint data set10.51.023

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS