Main Content

setAlgorithmParameters

Set algorithm parameters for lookup table function code replacement table entry

Description

example

setAlgorithmParameters(tableEntry, algParams) sets the algorithm parameters for the lookup table function identified in the code replacement table entry tableEntry.

Examples

collapse all

Create a code replacement table.

crTable = RTW.TflTable;

Create a table entry for a function.

tableEntry = RTW.TflCFunctionEntry;

Identify the table entry as an entry for the prelookup function.

setTflCFunctionEntryParameters(tableEntry, ...
    'Key', 'prelookup', ...
    'Priority', 100, ...
    'ImplementationName', 'Ifx_DpSearch_u8');

Get the algorithm parameter settings for the prelookup function table entry.

algParams = getAlgorithmParameters(tableEntry)
algParams = 

  Prelookup with properties:

             ExtrapMethod: [1x1 coder.algorithm.parameter.ExtrapMethod]
                  RndMeth: [1x1 coder.algorithm.parameter.RndMeth]
        IndexSearchMethod: [1x1 coder.algorithm.parameter.IndexSearchMethod]
        UseLastBreakpoint: [1x1 coder.algorithm.parameter.UseLastBreakpoint]
    RemoveProtectionInput: [1x1 coder.algorithm.parameter.RemoveProtectionInput]

Display the valid values for parameter UseLastBreakpoint for the prelookup function.

algParams.UseLastBreakpoint
ans = 

  UseLastBreakpoint with properties:

       Name: 'UseLastBreakpoint'
    Options: {'off'  'on'}
    Primary: 0
      Value: {'off'  'on'}

Display the valid values for parameter RemoveProtectionInput for the prelookup function.

algParams.RemoveProtectionInput
ans = 

  RemoveProtectionInput with properties:

       Name: 'RemoveProtectionInput'
    Options: {'off'  'on'}
    Primary: 0
      Value: {'off'  'on'}

Set parameters UseLastBreakpoint and RemoveProtectionInput to on and off, respectively.

algParams.UseLastBreakpoint = 'on';
algParams.RemoveProtectionInput = 'off';

When you set each parameter, the algorithm parameter software checks for and reports errors for invalid syntax, parameter names, and values.

Update the parameter settings for the code replacement table entry.

setAlgorithmParameters(tableEntry, algParams);

Get the new algorithm parameter settings for the prelookup function table entry.

algParams = getAlgorithmParameters(tableEntry);

Examine the new value for UseLastBreakpoint.

algParams.UseLastBreakpoint
ans = 

  UseLastBreakpoint with properties:

       Name: 'UseLastBreakpoint'
    Options: {'off'  'on'}
    Primary: 0
      Value: {'on'}

Examine the new value for RemoveProtectionInput.

algParams.RemoveProtectionInput
ans = 

  RemoveProtectionInput with properties:

       Name: 'RemoveProtectionInput'
    Options: {'off'  'on'}
    Primary: 0
      Value: {'off'}

Create a code replacement table.

crTable = RTW.TflTable;

Create a table entry for a function.

tableEntry = RTW.TflCFunctionEntry;

Identify the table entry as an entry for the lookup2D function.

setTflCFunctionEntryParameters(tableEntry, ...
    'Key', 'lookup2D', ...
    'Priority', 100, ...
    'ImplementationName', 'myLookup2D');

Get the algorithm parameter settings for the lookup2D function table entry.

algParams = getAlgorithmParameters(tableEntry)
algParams = 

  Lookup with properties:

                                InterpMethod: [1×1 coder.algorithm.parameter.InterpMethod]
                                ExtrapMethod: [1×1 coder.algorithm.parameter.ExtrapMethod]
                        UseRowMajorAlgorithm: [1×1 coder.algorithm.parameter.UseRowMajorAlgorithm]
                                     RndMeth: [1×1 coder.algorithm.parameter.RndMeth]
                           IndexSearchMethod: [1×1 coder.algorithm.parameter.IndexSearchMethod]
                           UseLastTableValue: [1×1 coder.algorithm.parameter.UseLastTableValue]
    ApplyFullPrecisionForLinearInterpolation: [1×1 coder.algorithm.parameter.ApplyFullPrecisionForLinearInterpolation]
                       RemoveProtectionInput: [1×1 coder.algorithm.parameter.RemoveProtectionInput]
                   SaturateOnIntegerOverflow: [1×1 coder.algorithm.parameter.SaturateOnIntegerOverflow]
                     SupportTunableTableSize: [1×1 coder.algorithm.parameter.SupportTunableTableSize]
                             BPPower2Spacing: [1×1 coder.algorithm.parameter.BPPower2Spacing]
    BeginIndexSearchUsingPreviousIndexResult: [1×1 coder.algorithm.parameter.BeginIndexSearchUsingPreviousIndexResult]

Display the valid values for algorithm parameter IndexSearchMethod for the lookup2D function.

algParams.IndexSearchMethod
ans = 

  IndexSearchMethod with properties:

       Name: 'IndexSearchMethod'
    Options: {'Linear search'  'Binary search'  'Evenly spaced points'}
    Primary: 0
      Value: {'Binary search'  'Evenly spaced points'  'Linear search'}

Set parameter IndexSearchMethod to Evenly spaced points.

algParams.IndexSearchMethod = 'Evenly spaced point';
Error using coder.algorithm.parameter.validateValue (line 58)
Invalid value '{Evenly spaced point}' for algorithm parameter
'coder.algorithm.parameter.IndexSearchMethod'. Valid values are '{Linear
search, Binary search, Evenly spaced points}'.

Error in coder.algorithm.parameter.AlgorithmParameter/set.Value (line 49)
            obj.Value = coder.algorithm.parameter.validateValue(obj, val);
            
Error in coder.algorithm.parameter.AlgorithmParameter/setAP (line 36)
                obj.Value = value;

Error in coder.algorithm.parameterset.Lookup/set.IndexSearchMethod (line 39)
            obj.IndexSearchMethod = obj.IndexSearchMethod.setAP(value);

The code replacement software flags the ‘s’ that is missing from ‘points’.

Adjust the parameter setting.

algParams.IndexSearchMethod = 'Evenly spaced points';

Update the parameter settings for the code replacement table entry.

setAlgorithmParameters(tableEntry, algParams);

Get the updated algorithm parameter settings for the lookup2D function table entry.

algParams = getAlgorithmParameters(tableEntry);

Verify the new value of IndexSearchMethod.

algParams.IndexSearchMethod
ans = 

  IndexSearchMethod with properties:

       Name: 'IndexSearchMethod'
    Options: {'Linear search'  'Binary search'  'Evenly spaced points'}
    Primary: 0
      Value: {'Evenly spaced points'}

Input Arguments

collapse all

Code replacement table entry that you previously created and represents a potential code replacement for a lookup table function. The entry must identify the lookup table function for which you are calling setAlgorithmParameters.

  1. Create the entry. For example, call the function RTW.TflCFunctionEntry.

    tableEntry = RTW.TflCFunctionEntry;

  2. Specify the name of the lookup table function for which you created the entry. Use the Key parameter in a call to setTflCFunctionEntryParameters. The following function call specifies the lookup table function prelookup.

    setTflCFunctionEntryParameters(tableEntry, ...
       'Key', 'prelookup', ...
       'Priority', 100, ...
       'ImplementationName', 'Ifx_DpSearch_u8'); 

Algorithm parameter settings for the lookup table function identified with the Key parameter in tableEntry.

Version History

Introduced in R2015a