Создайте объект FunctionApproximation.Problem
, задающий функцию, которую вы хотите аппроксимировать.
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]
Используйте значения по умолчанию для всех других опций. Аппроксимируйте функцию tanh
использование метода solve
.
| 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"
Сравните исходную функцию и приближение функций.
data = struct with fields:
Breakpoints: [65536x1 double]
Original: [65536x1 double]
Approximate: [65536x1 double]