This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

approximate

Class: FunctionApproximation.LUTSolution
Package: FunctionApproximation

Generate a Lookup Table block from a FunctionApproximation.LUTSolution

Syntax

approximate(solution)

Description

approximate(solution) generates a Simulink model containing a subsystem made up of the Lookup Table block with data and breakpoints specified by the FunctionApproximation.LUTSolution object, solution. The generated Lookup Table block is surrounded with Data Type Conversion blocks.

Input Arguments

expand all

The solution to generate a lookup table from, specified as a FunctionApproximation.LUTSolution object.

Examples

expand all

Create a FunctionApproximation.Problem object defining the function you want to approximate.

problem = FunctionApproximation.Problem('tanh')
problem = 

  1x1 FunctionApproximation.Problem with properties:

    FunctionToApproximate: @(x)tanh(x)
           NumberOfInputs: 1
               InputTypes: "numerictype(1,16,12)"
         InputLowerBounds: -8
         InputUpperBounds: 8
               OutputType: "numerictype(1,16,15)"
                  Options: [1x1 FunctionApproximation.Options]

Use default values for all other options. Approximate the tanh function using the solve method.

solution = solve(problem)
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) | 
|   0 |             64 |        0 |          2 |              16 |           16 |             EvenSpacing |     7.812500e-03, 9.999998e-01 |
|   1 |           1072 |        1 |         65 |              16 |           16 |             EvenSpacing |     7.812500e-03, 5.969045e-03 |
|   2 |            560 |        0 |         33 |              16 |           16 |             EvenSpacing |     7.812500e-03, 2.332596e-02 |
|   3 |            816 |        0 |         49 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.010471e-02 |
|   4 |            944 |        1 |         57 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.780470e-03 |
|   5 |            880 |        0 |         53 |              16 |           16 |             EvenSpacing |     7.812500e-03, 8.881069e-03 |
|   6 |            912 |        0 |         55 |              16 |           16 |             EvenSpacing |     7.812500e-03, 8.316993e-03 |
|   7 |            928 |        0 |         56 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.990307e-03 |
|   8 |            448 |        1 |         14 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.798151e-03 |

Best Solution
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) |
|   8 |            448 |        1 |         14 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.798151e-03 |


solution = 

  1x1 FunctionApproximation.LUTSolution with properties:

          ID: 8
    Feasible: "true"

Generate a Simulink™ subsystem containing a Lookup Table block approximating the tanh function.

approximate(solution)

Introduced in R2018a