replaceWithApproximate
Class: FunctionApproximation.LUTSolution
Namespace: FunctionApproximation
Replace block with the generated lookup table approximation
Syntax
replaceWithApproximate(solution)
Description
replaceWithApproximate(
replaces the
simulink block with its lookup table approximation, generated using the solution
)approximate
method of the FunctionApproximation.LUTSolution
object.
Input Arguments
solution
— Solution to use to replace the source block
FunctionApproximation.LUTSolution
object
Solution to replace the source block, specified as a FunctionApproximation.LUTSolution
object.
Examples
Replace a Block with an Approximation
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)
Searching for fixed-point solutions. | ID | Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification | Error(Max,Current) | | 0 | 48 | 0 | 2 | 8 | 16 | EvenSpacing | 7.812500e-03, 9.471100e+00 | | 1 | 800 | 0 | 49 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497029e-01 | | 2 | 1584 | 1 | 98 | 8 | 16 | EvenSpacing | 7.812500e-03, 1.016505e-05 | | 3 | 1056 | 0 | 65 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497029e-01 | | 4 | 544 | 0 | 33 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497029e-01 | | 5 | 416 | 0 | 25 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.497029e-01 | | 6 | 368 | 0 | 22 | 8 | 16 | EvenSpacing | 7.812500e-03, 4.534664e+00 | | 7 | 64 | 0 | 2 | 16 | 16 | EvenSpacing | 7.812500e-03, 9.517788e+00 | | 8 | 768 | 1 | 46 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.192364e-04 | | 9 | 752 | 1 | 45 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.220687e-04 | | 10 | 592 | 1 | 35 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.388241e-04 | | 11 | 576 | 1 | 34 | 16 | 16 | EvenSpacing | 7.812500e-03, 6.201875e-05 | | 12 | 416 | 0 | 24 | 16 | 16 | EvenSpacing | 7.812500e-03, 8.559014e-01 | | 13 | 400 | 0 | 23 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.008229e+00 | | 14 | 496 | 0 | 29 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.136958e-01 | | 15 | 528 | 1 | 31 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.018354e-04 | | 16 | 512 | 0 | 30 | 16 | 16 | EvenSpacing | 7.812500e-03, 1.037605e-01 | | 17 | 288 | 0 | 16 | 16 | 16 | EvenSpacing | 7.812500e-03, 2.391904e+00 | | 18 | 464 | 0 | 27 | 16 | 16 | EvenSpacing | 7.812500e-03, 4.491186e-01 | | 19 | 80 | 0 | 2 | 8 | 32 | EvenSpacing | 7.812500e-03, 9.471052e+00 | | 20 | 48 | 0 | 2 | 8 | 16 | EvenPow2Spacing | 7.812500e-03, 1.146582e+01 | | 21 | 416 | 0 | 25 | 8 | 16 | EvenPow2Spacing | 7.812500e-03, 4.497029e-01 | | 22 | 224 | 0 | 13 | 8 | 16 | EvenPow2Spacing | 7.812500e-03, 2.887487e+00 | | 23 | 64 | 0 | 2 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 1.145654e+01 | | 24 | 432 | 0 | 25 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 6.957588e-01 | | 25 | 240 | 0 | 13 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 3.221296e+00 | | 26 | 80 | 0 | 2 | 8 | 32 | EvenPow2Spacing | 7.812500e-03, 1.146600e+01 | | 27 | 432 | 0 | 13 | 8 | 32 | EvenPow2Spacing | 7.812500e-03, 2.887556e+00 | | 28 | 96 | 0 | 2 | 16 | 32 | EvenPow2Spacing | 7.812500e-03, 1.145661e+01 | | 29 | 448 | 0 | 13 | 16 | 32 | EvenPow2Spacing | 7.812500e-03, 3.221186e+00 | | 30 | 128 | 0 | 2 | 32 | 32 | EvenPow2Spacing | 7.812500e-03, 1.145660e+01 | | 31 | 480 | 0 | 13 | 32 | 32 | EvenPow2Spacing | 7.812500e-03, 3.220685e+00 | | 32 | 96 | 0 | 2 | 32 | 16 | EvenPow2Spacing | 7.812500e-03, 1.145654e+01 | | 33 | 464 | 0 | 25 | 32 | 16 | EvenPow2Spacing | 7.812500e-03, 6.951333e-01 | | 34 | 272 | 0 | 13 | 32 | 16 | EvenPow2Spacing | 7.812500e-03, 3.220611e+00 | | 35 | 216 | 1 | 9 | 8 | 16 | ExplicitValues | 7.812500e-03, 9.900552e-04 | | 36 | 192 | 0 | 8 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.142949e-02 | | 37 | 192 | 0 | 8 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.142949e-02 | | 38 | 192 | 0 | 8 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.142949e-02 | | 39 | 192 | 0 | 8 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.142949e-02 | | 40 | 192 | 1 | 8 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.383244e-03 | Searching for floating-point solutions. | 41 | 64 | 0 | 2 | 16 | 16 | EvenSpacing | 7.812500e-03, 9.424033e+00 | | 42 | 768 | 0 | 46 | 16 | 16 | EvenSpacing | 7.812500e-03, 9.531209e-01 | | 43 | 752 | 1 | 45 | 16 | 16 | EvenSpacing | 7.812500e-03, 3.864191e-05 | | 44 | 160 | 0 | 2 | 16 | 64 | EvenSpacing | 7.812500e-03, 9.421379e+00 | | 45 | 64 | 0 | 2 | 16 | 16 | EvenPow2Spacing | 7.812500e-03, 1.145605e+01 | | 46 | 160 | 0 | 2 | 16 | 64 | EvenPow2Spacing | 7.812500e-03, 1.145598e+01 | Best Solution | ID | Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification | Error(Max,Current) | | 40 | 192 | 1 | 8 | 8 | 16 | ExplicitValues | 7.812500e-03, 1.383244e-03 | solution = 1x1 FunctionApproximation.LUTSolution with properties: ID: 40 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)
Version History
Introduced in R2018b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)