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.

replaceWithApproximate

Class: FunctionApproximation.LUTSolution
Package: FunctionApproximation

Replace block with the generated lookup table approximation

Syntax

replaceWithApproximate(solution)

Description

replaceWithApproximate(solution) replaces the simulink block with its lookup table approximation, generated using the approximate method of the FunctionApproximation.LUTSolution object.

Input Arguments

expand all

Solution to replace the source block, specified as a FunctionApproximation.LUTSolution object.

Examples

expand all

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 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.018476e+01 |
|   1 |             80 |        0 |          4 |               8 |           16 |             EvenSpacing |     7.812500e-03, 8.165374e+00 |
|   2 |            144 |        0 |          8 |               8 |           16 |             EvenSpacing |     7.812500e-03, 5.009787e+00 |
|   3 |            288 |        0 |         17 |               8 |           16 |             EvenSpacing |     7.812500e-03, 1.721082e+00 |
|   4 |            544 |        0 |         33 |               8 |           16 |             EvenSpacing |     7.812500e-03, 4.497030e-01 |
|   5 |           1056 |        0 |         65 |               8 |           16 |             EvenSpacing |     7.812500e-03, 4.497030e-01 |
|   6 |           3136 |        1 |        195 |               8 |           16 |             EvenSpacing |     7.812500e-03, 1.016648e-05 |
|   7 |             64 |        0 |          2 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.023523e+01 |
|   8 |             96 |        0 |          4 |              16 |           16 |             EvenSpacing |     7.812500e-03, 8.295461e+00 |
|   9 |            160 |        0 |          8 |              16 |           16 |             EvenSpacing |     7.812500e-03, 5.316993e+00 |
|  10 |            288 |        0 |         16 |              16 |           16 |             EvenSpacing |     7.812500e-03, 2.386664e+00 |
|  11 |            544 |        1 |         32 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.100154e-04 |
|  12 |            416 |        0 |         24 |              16 |           16 |             EvenSpacing |     7.812500e-03, 8.542946e-01 |
|  13 |            480 |        0 |         28 |              16 |           16 |             EvenSpacing |     7.812500e-03, 3.269081e-01 |
|  14 |            512 |        0 |         30 |              16 |           16 |             EvenSpacing |     7.812500e-03, 9.907877e-02 |
|  15 |            528 |        1 |         31 |              16 |           16 |             EvenSpacing |     7.812500e-03, 1.018420e-04 |
|  16 |             80 |        0 |          2 |               8 |           32 |             EvenSpacing |     7.812500e-03, 1.018479e+01 |
|  17 |            144 |        0 |          4 |               8 |           32 |             EvenSpacing |     7.812500e-03, 8.165347e+00 |
|  18 |            272 |        0 |          8 |               8 |           32 |             EvenSpacing |     7.812500e-03, 5.009844e+00 |
|  19 |            208 |        0 |          6 |               8 |           32 |             EvenSpacing |     7.812500e-03, 6.322025e+00 |
|  20 |            240 |        0 |          7 |               8 |           32 |             EvenSpacing |     7.812500e-03, 5.686642e+00 |
|  21 |             48 |        0 |          2 |               8 |           16 |         EvenPow2Spacing |     7.812500e-03, 1.018476e+01 |
|  22 |             80 |        0 |          4 |               8 |           16 |         EvenPow2Spacing |     7.812500e-03, 8.165374e+00 |
|  23 |            224 |        0 |         13 |               8 |           16 |         EvenPow2Spacing |     7.812500e-03, 2.883145e+00 |
|  24 |            416 |        0 |         25 |               8 |           16 |         EvenPow2Spacing |     7.812500e-03, 1.928802e-01 |
|  25 |             64 |        0 |          2 |              16 |           16 |         EvenPow2Spacing |     7.812500e-03, 1.023523e+01 |
|  26 |             96 |        0 |          4 |              16 |           16 |         EvenPow2Spacing |     7.812500e-03, 8.277203e+00 |
|  27 |            240 |        0 |         13 |              16 |           16 |         EvenPow2Spacing |     7.812500e-03, 3.220263e+00 |
|  28 |            432 |        0 |         25 |              16 |           16 |         EvenPow2Spacing |     7.812500e-03, 6.954880e-01 |
|  29 |             80 |        0 |          2 |               8 |           32 |         EvenPow2Spacing |     7.812500e-03, 1.018479e+01 |
|  30 |            144 |        0 |          4 |               8 |           32 |         EvenPow2Spacing |     7.812500e-03, 8.165347e+00 |
|  31 |            432 |        0 |         13 |               8 |           32 |         EvenPow2Spacing |     7.812500e-03, 2.883217e+00 |
|  32 |             96 |        0 |          2 |              16 |           32 |         EvenPow2Spacing |     7.812500e-03, 1.023510e+01 |
|  33 |            160 |        0 |          4 |              16 |           32 |         EvenPow2Spacing |     7.812500e-03, 8.277072e+00 |
|  34 |            448 |        0 |         13 |              16 |           32 |         EvenPow2Spacing |     7.812500e-03, 3.220151e+00 |
|  35 |            128 |        0 |          2 |              32 |           32 |         EvenPow2Spacing |     7.812500e-03, 1.023418e+01 |
|  36 |            192 |        0 |          4 |              32 |           32 |         EvenPow2Spacing |     7.812500e-03, 8.276246e+00 |
|  37 |            480 |        0 |         13 |              32 |           32 |         EvenPow2Spacing |     7.812500e-03, 3.219648e+00 |
|  38 |             96 |        0 |          2 |              32 |           16 |         EvenPow2Spacing |     7.812500e-03, 1.023404e+01 |
|  39 |            128 |        0 |          4 |              32 |           16 |         EvenPow2Spacing |     7.812500e-03, 8.276123e+00 |
|  40 |            272 |        0 |         13 |              32 |           16 |         EvenPow2Spacing |     7.812500e-03, 3.219573e+00 |
|  41 |            464 |        0 |         25 |              32 |           16 |         EvenPow2Spacing |     7.812500e-03, 6.948634e-01 |
|  42 |            216 |        1 |          9 |               8 |           16 |          ExplicitValues |     7.812500e-03, 7.187706e-03 |

Best Solution
|  ID |  Memory (bits) | Feasible | Table Size | Breakpoints WLs | TableData WL | BreakpointSpecification |             Error(Max,Current) |
|  42 |            216 |        1 |          9 |               8 |           16 |          ExplicitValues |     7.812500e-03, 7.187706e-03 |


solution = 

  1x1 FunctionApproximation.LUTSolution with properties:

          ID: 42
    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)

Introduced in R2018b