Hauptinhalt

getErrorValue

R2026b

Class: FunctionApproximation.LUTSolution
Namespace: FunctionApproximation

Get total error of the lookup table approximation

Syntax

error = getErrorValue(solution)

Description

error = getErrorValue(solution) returns the total error of the lookup table approximation specified by solution.

Input Arguments

expand all

Solution to get error of, specified as a FunctionApproximation.LUTSolution object.

Output Arguments

expand all

Total error of the lookup table approximation, returned as a structure.

The structure contains two fields:

  • The MaxErrorInSolution field specifies the maximum difference between the original function or block and the lookup table approximation.

  • The ErrorUpperBound field specifies the maximum error that was acceptable according to the tolerances specified in the FunctionApproximation.Options object.

Examples

expand all

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

Calculate the total error of the FunctionApproximation.LUTSolution object using the getErrorValue method.

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

  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: [1×1 FunctionApproximation.Options]
solution = solve(problem)
solution = 

  FunctionApproximation.LUTSolution with properties

          ID: 8
    Feasible: "true"
error = getErrorValue(solution)
error = 

  struct with fields:

    MaxErrorInSolution: 0.0073
       ErrorUpperBound: 0.0078

Use the example Approximate Multiple Math Functions to generate a FunctionApproximation.LUTSolution object that contains two lookup table approximations, multiFunctionSolution. Calculate the total error.

error = getErrorValue(multiFunctionSolution)
error = 

  struct with fields:

    MaxErrorInSolution: [0.0078 0.0078]
       ErrorUpperBound: [0.0078 0.0078]

The error is reported in ordered arrays. Each element in the array corresponds to the function in the same position of the cell array passed to the FunctionApproximation.Problem object.

Version History

Introduced in R2019a