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 |           1248 |        1 |         76 |              16 |           16 |             EvenSpacing |     7.812500e-03, 4.368265e-03 |
|   2 |           1232 |        1 |         75 |              16 |           16 |             EvenSpacing |     7.812500e-03, 4.439035e-03 |
|   3 |            944 |        1 |         57 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.780470e-03 |
|   4 |            928 |        1 |         56 |              16 |           16 |             EvenSpacing |     7.812500e-03, 6.110240e-03 |
|   5 |            656 |        0 |         39 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.678519e-02 |
|   6 |            640 |        0 |         38 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.660649e-02 |
|   7 |            784 |        0 |         47 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.102459e-02 |
|   8 |            848 |        1 |         51 |              16 |           16 |             EvenSpacing |     7.812500e-03, 6.211764e-03 |
|   9 |            816 |        1 |         49 |              16 |           16 |             EvenSpacing |     7.812500e-03, 6.811833e-03 |
|  10 |            800 |        0 |         48 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.105540e-02 |
|  11 |            432 |        0 |         25 |              16 |           16 |             EvenSpacing |     7.812500e-03, 3.532625e-02 |
|  12 |            624 |        0 |         37 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.870074e-02 |
|  13 |            720 |        0 |         43 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.355547e-02 |
|  14 |            768 |        0 |         46 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.199717e-02 |
|  15 |            384 |        1 |         12 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.812317e-03 |
|  16 |            384 |        0 |         12 |              16 |           16 |          ExplicitValues |     7.812500e-03, 1.196141e-02 |
|  17 |            384 |        1 |         12 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.812317e-03 |

Best Solution
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) |
|  15 |            384 |        1 |         12 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.812317e-03 |


solution = 

  1x1 FunctionApproximation.LUTSolution with properties:

          ID: 15
    Feasible: "true"

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

approximate(solution)

Introduced in R2018a