Main Content


Create function entry based on specified parameters and register in code replacement table



entry = registerCFunctionEntry(hTable,priority,numInputs,functionName,inputType,implementationName,outputType,headerFile,genCallback,genFileName) provides a quick way to create and register a code replacement function entry.

This function can be used only if your function entry meets the following conditions:

  • The input arguments are of the same type.

  • The input argument names and the return argument name follow the default Simulink® naming convention:

    • For input argument names, u1, u2, ..., un

    • For return argument, y1


collapse all

This example shows how to use the registerCFunctionEntry function to create a C function entry for sqrt in a code replacement table.

hLib = RTW.TflTable;

hLib.registerCFunctionEntry(100, 1, 'sqrt', 'double', 'sqrt', ...
                            'double', '<math.h>', '', '');

Input Arguments

collapse all

The hTable is a handle to a code replacement table previously returned by hTable = RTW.TflTable.

Example: hLib

The priority specifies the search priority of the function entry, relative to other entries of the same function name and conceptual argument list within this table. Highest priority is 0, and lowest priority is 100. If the table provides two implementations for a function, the implementation with the higher priority shadows the one with the lower priority.

Example: 100

Example: 1

The functionName specifies the name of the function to replace. The name must match a function name listed in “Code You Can Replace” in What Is Code Replacement Customization? (MATLAB® code) or What Is Code Replacement Customization? (Simulink models).

Example: 'sqrt'

This function requires that the input arguments are of the same type.

Example: 'double'

The implementationName specifies the name of the implementation. For example, if functionName is 'sqrt', implementationName can be 'sqrt' or a different name.

Example: 'sqrt'

Example: 'double'

Example: '<math.h>'

The genCallback specifies a callback that follows code generation. If you specify 'RTW.copyFileToBuildDir', and if this function entry is matched and used, the code generator calls function RTW.copyFileToBuildDir after code generation. This callback function copies additional header, source, or object files that you have specified for this function entry to the build folder.

Example: ''

This argument is reserved for MathWorks developers.

Example: ''

Output Arguments

collapse all

The entry is a handle to the created code replacement function entry. Specifying the return argument in the registerCFunctionEntry function call is optional.

Version History

Introduced in R2007b