Class: FunctionApproximation.LUTSolution
Package: FunctionApproximation
Replace block with the generated lookup table approximation
replaceWithApproximate(solution)
replaceWithApproximate(
replaces the
simulink block with its lookup table approximation, generated using the solution
)approximate
method of the FunctionApproximation.LUTSolution
object.
solution
— Solution to use to replace the source blockFunctionApproximation.LUTSolution
objectSolution to replace the source block, specified as a FunctionApproximation.LUTSolution
object.
This example shows how to approximate a block using a lookup table approximation, replace the original block with the approximation, and then revert the block back to its original state.
Open the model containing the block to approximate. In this example, replace the tan block with a lookup table approximation.
open_system('ex_luto_approx')
Create a FunctionApproximation.Problem
object specifying what you want to approximate.
problem = FunctionApproximation.Problem('ex_luto_approx/Trigonometric Function')
problem = 1x1 FunctionApproximation.Problem with properties: FunctionToApproximate: 'ex_luto_approx/Trigonometric Function' NumberOfInputs: 1 InputTypes: "numerictype('double')" InputLowerBounds: -1.5083 InputUpperBounds: 1.5083 OutputType: "numerictype('double')" Options: [1x1 FunctionApproximation.Options]
Use default values for all other options. To approximate the block use the solve
method.
solution = solve(problem)
| ID | Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification | Error(Max,Current) | | 0 | 48 | 0 | 2 | 8 | 16 | EvenSpacing | 7.812500e-03, 1.146582e+01 | | 1 | 800 | 0 | 49 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497030e-01 | | 2 | 1584 | 1 | 98 | 8 | 16 | EvenSpacing | 7.812500e-03, 1.016505e-05 | | 3 | 640 | 0 | 39 | 8 | 16 | EvenSpacing | 7.812500e-03, 3.533199e+00 | | 4 | 416 | 0 | 25 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497030e-01 | | 5 | 1056 | 0 | 65 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497030e-01 | | 6 | 64 | 0 | 2 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.145654e+01 | | 7 | 768 | 1 | 46 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.192364e-04 | | 8 | 752 | 1 | 45 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.220687e-04 | | 9 | 592 | 1 | 35 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.388241e-04 | | 10 | 576 | 1 | 34 | 16 | 16 | EvenSpacing | 7.812500e-03, 6.201875e-05 | | 11 | 416 | 0 | 24 | 16 | 16 | EvenSpacing | 7.812500e-03, 8.559014e-01 | | 12 | 400 | 0 | 23 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.008229e+00 | | 13 | 496 | 0 | 29 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.136958e-01 | | 14 | 528 | 1 | 31 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.018354e-04 | | 15 | 512 | 0 | 30 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.037605e-01 | | 16 | 80 | 0 | 2 | 8 | 32 | EvenSpacing | 7.812500e-03, 1.146600e+01 | | 17 | 48 | 0 | 2 | 8 | 16 | EvenPow2Spacing | 7.812500e-03, 1.146582e+01 | | 18 | 64 | 0 | 2 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 1.145654e+01 | | 19 | 80 | 0 | 2 | 8 | 32 | EvenPow2Spacing | 7.812500e-03, 1.146600e+01 | | 20 | 96 | 0 | 2 | 16 | 32 | EvenPow2Spacing | 7.812500e-03, 1.145661e+01 | | 21 | 128 | 0 | 2 | 32 | 32 | EvenPow2Spacing | 7.812500e-03, 1.145660e+01 | | 22 | 96 | 0 | 2 | 32 | 16 | EvenPow2Spacing | 7.812500e-03, 1.145654e+01 | | 23 | 216 | 0 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.057648e-02 | | 24 | 216 | 1 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 7.187595e-03 | | 25 | 216 | 0 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.057648e-02 | | 26 | 216 | 0 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.036807e-02 | | 27 | 216 | 1 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 7.187595e-03 | | 28 | 144 | 0 | 2 | 8 | 64 | EvenSpacing | 7.812500e-03, 1.195947e+01 | | 29 | 144 | 0 | 2 | 8 | 64 | EvenPow2Spacing | 7.812500e-03, 1.195947e+01 | Best Solution | ID | Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification | Error(Max,Current) | | 24 | 216 | 1 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 7.187595e-03 | solution = 1x1 FunctionApproximation.LUTSolution with properties: ID: 24 Feasible: "true"
Generate a Simulink™ subsystem containing the lookup table approximation using the approximate
method.
approximate(solution)
Replace the original block with the approximation.
replaceWithApproximate(solution)
You can revert the system back to its original state using the revertToOriginal
method.
revertToOriginal(solution)
You have a modified version of this example. Do you want to open this example with your edits?