addAlgorithmProperty
R2026bAdd algorithm properties for code replacement table entry
Description
addAlgorithmProperty(
adds algorithm property settings to the conceptual
representation of a code replacement table entry.
For example, use this function to adjust the
algorithms applied by lookup table
functions.hEntry,Name=Value)
Examples
This example shows how to use the
addAlgorithmPropertyfunction to configure the code generator to apply these methods when replacing code for thelookup1Dfunction:Clip extrapolation
Linear interpolation
Binary or linear index search
hLib = RTW.TflTable; hEnt = RTW.TflCFunctionEntry; hEnt.setTflCFunctionEntryParameters( ... Key="lookup1D", ... Priority=100, ... ImplementationName="my_Lookup1D_Repl", ... ImplementationHeaderFile="my_Lookup1D.h", ... ImplementationSourceFile="my_Lookup1D.c", ... GenCallback="RTW.copyFileToBuildDir"); arg = hEnt.getTflArgFromString('y1','double'); arg.IOType = 'RTW_IO_OUTPUT'; hEnt.addConceptualArg(arg); arg = hEnt.getTflArgFromString('u1','double'); hEnt.addConceptualArg(arg); arg = RTW.TflArgMatrix('u2','RTW_IO_INPUT','double'); arg.DimRange = [0 0; Inf Inf]; hEnt.addConceptualArg(arg); arg = RTW.TflArgMatrix('u3', 'RTW_IO_INPUT', 'double'); arg.DimRange = [0 0; Inf Inf]; hEnt.addConceptualArg(arg); hEnt.addAlgorithmProperty(ExtrapMethod="Clip"); hEnt.addAlgorithmProperty(InterpMethod="Linear point-slope"); hEnt.addAlgorithmProperty(IndexSearchMethod="Linear search");
Input Arguments
Code replacement table entry, previously
returned by calling the function
RTW.TflCFunctionEntry or
RTW.TflCOperationEntry.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: Name=y1
In a lookup table block, the
ApplyFullPrecisionForLinearInterpolation
value specifies whether or not to use
full-precision fixed-point algorithm for linear
interpolation lookup when possible. For a code
replacement entry, the value specifies whether to
match generated lookup functions that use
full-precision table lookup.
If you set
ApplyFullPrecisionForLinearInterpolation
to on in a code replacement entry:
If the value on the block is set to
onbut the code generator was not able to use the full-precision fixed-point algorithm for the generated lookup function, the entry does not match the generated function.A match can cause a numerical mismatch between simulation and code generation if the implementation algorithm is different from the algorithm used for simulation.
Set the BPPower2Spacing
value to on if you want to
replace blocks whose breakpoints are the power of
2 spaced values by the user-defined function
specified in the code replacement library. Set the
value to off if you want to
replace blocks whose breakpoints are not the power
of 2 spaced values by the user-defined function
specified in the code replacement library.
The ExtrapMethod value
specifies which method to use to extrapolate
values for inputs that fall outside the range of a
breakpoint data set.
Example: ExtrapMethod="Clip"
The IndexSearchMethod
value specifies the method of calculating table
indices. For evenly spaced breakpoint sets, you
achieve optimal speed by selecting Evenly
spaced points to calculate table
indices. For unevenly spaced breakpoint sets, use
Linear search or
Binary search.
Example: IndexSearchMethod="Evenly
spaced points"
The InterpMethod value
specifies the method of interpolation between
breakpoint values.
Example: InterpMethod="Linear
point-slope"
The RemoveProtectionInput
value specifies whether or not to include code
that checks for out-of-range input values. If your
input values are not out of range, you can set the
RemoveProtectionInput to
off.
Example: RemoveProtectionInput="off"
The RndMeth value
specifies the rounding mode for fixed-point lookup
table calculations.
Example: RndMeth="Zero"
The
SaturateOnIntegerOverflow value
specifies the method of overflow action. If you
set the value to off, overflows
wrap to the
appropriate value
that is represented by the data type. Otherwise,
overflows saturate to either the minimum or
maximum value that the data type can
represent.
Example: SaturateOnIntegerOverflow="on"
If you want to enable tunable table size in
the generated code, set the
SupportTunableTableSize value
to on.
Example: SupportTunableTableSize="on"
The UseLastTableValue
value specifies the indexing convention to use to
address the last element of a breakpoint set and
its corresponding table value.
Example: UseLastTableValue="on"
Set the
UseRowMajorAlgorithm value to
on to enable using row-major
algorithms. Set the value to
off to use column-major
algorithms.
Example: UseRowMajorAlgorithm="on"
Version History
Introduced in R2014b
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)