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.

compare

Class: FunctionApproximation.LUTSolution
Package: FunctionApproximation

Compare numerical results of FunctionApproximation.LUTSolution to original function or lookup table

Syntax

data = compare(solution)

Description

data = compare(solution) plots the difference between the data contained in the FunctionApproximation.LUTSolution object, solution, and the original lookup table, function, or Math Function block.

Input Arguments

expand all

The solution to compare original behavior against, specified as a FunctionApproximation.LUTSolution object.

Output Arguments

expand all

Struct containing data comparing the original function or lookup table and the approximation contained in the solution.

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"

Compare the original function and the function approximation.

data = compare(solution)

data = struct with fields:
    Breakpoints: [65536x1 double]
       Original: [65536x1 double]
    Approximate: [65536x1 double]

Introduced in R2018a