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.

solutionfromID

Class: FunctionApproximation.LUTSolution
Package: FunctionApproximation

Access a solution found during the approximation process

Syntax

other_solution = solutionfromID(solution,id)

Description

other_solution = solutionfromID(solution,id) returns the solution associated with the FunctionApproximation.LUTSolution object, solution, with the ID specified by id.

Input Arguments

expand all

The solution object containing the solution you want to explore, specified as a FunctionApproximation.LUTSolution object.

ID of the solution that you want to explore, specified as a scalar integer.

Data Types: double

Output Arguments

expand all

FunctionApproximation.LUTSolution object associated with the specified ID.

Examples

expand all

This example shows how to use the solutionfromID method of the FunctionApproximation.LUTSolution object to examine other approximation solutions.

Create a FunctionApproximation.Problem object defining a math function to approximate. Then use the solve method to get a FunctionApproximation.LUTSolution object.

problem = FunctionApproximation.Problem('sin')
problem = 
  1x1 FunctionApproximation.Problem with properties:

    FunctionToApproximate: @(x)sin(x)
           NumberOfInputs: 1
               InputTypes: "numerictype(0,16,13)"
         InputLowerBounds: 0
         InputUpperBounds: 6.2832
               OutputType: "numerictype(1,16,14)"
                  Options: [1x1 FunctionApproximation.Options]

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, 1.000000e+00 |
|   1 |            560 |        1 |         33 |              16 |           16 |             EvenSpacing |     7.812500e-03, 4.844995e-03 |
|   2 |            304 |        0 |         17 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.887217e-02 |
|   3 |            432 |        0 |         25 |              16 |           16 |             EvenSpacing |     7.812500e-03, 8.539386e-03 |
|   4 |            496 |        1 |         29 |              16 |           16 |             EvenSpacing |     7.812500e-03, 6.319763e-03 |
|   5 |            464 |        1 |         27 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.324035e-03 |
|   6 |            448 |        0 |         26 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.926903e-03 |
|   7 |             64 |        0 |          2 |              16 |           16 |         EvenPow2Spacing |     7.812500e-03, 1.315166e+00 |
|   8 |            448 |        0 |         26 |              16 |           16 |         EvenPow2Spacing |     7.812500e-03, 3.322094e-02 |
|   9 |            640 |        1 |         20 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.784160e-03 |

Best Solution
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) |
|   5 |            464 |        1 |         27 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.324035e-03 |
solution = 
  1x1 FunctionApproximation.LUTSolution with properties:

          ID: 5
    Feasible: "true"

Display all feasible solutions found during the approximation process.

displayfeasiblesolutions(solution)
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) | 
|   1 |            560 |        1 |         33 |              16 |           16 |             EvenSpacing |     7.812500e-03, 4.844995e-03 |
|   4 |            496 |        1 |         29 |              16 |           16 |             EvenSpacing |     7.812500e-03, 6.319763e-03 |
|   5 |            464 |        1 |         27 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.324035e-03 |
|   9 |            640 |        1 |         20 |              16 |           16 |          ExplicitValues |     7.812500e-03, 7.784160e-03 |

Best Solution
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) |
|   5 |            464 |        1 |         27 |              16 |           16 |             EvenSpacing |     7.812500e-03, 7.324035e-03 |

Solution with ID 5 is not listed as a feasible solution in the table. Explore this solution to see why it is not feasible.

solution5 = solutionfromID(solution, 5)
solution5 = 
  1x1 FunctionApproximation.LUTSolution with properties:

          ID: 5
    Feasible: "true"

Compare the numerical behavior of the solution with ID 5.

compare(solution5)

ans = struct with fields:
    Breakpoints: [51473x1 double]
       Original: [51473x1 double]
    Approximate: [51473x1 double]

You can see from the plot that the solution does not meet the required tolerances.

Introduced in R2018a