Main Content

find

Get model elements for the category of model code mappings

Since R2021a

    Description

    modelElementsFound = find(myCPPMappingObj,category) returns the elements in the model code mappings of the specified category as an array of objects.

    example

    modelElementsFound = find(myCPPMappingObj,category,'MethodName', methodName) returns the model functions in the model code mappings with the specified method name.

    example

    Examples

    collapse all

    You can use the find function to find all model elements of a specific category in the code mappings.

    Open the model. To access the CodeMappingCPP object associated with the model, use the coder.mapping.api.get function.

    open_system('CppClassWorkflowKeyIgnition');
    cm = coder.mapping.api.get('CppClassWorkflowKeyIgnition');

    Find all functions with an unset method name by using the find function.

    unsetMethods = find(cm, 'Functions', 'MethodName', '')
    unsetMethods = 1x4 string
        "Initialize"    "Terminate"    "Periodic:D1"    "Periodic:D2"
    
    

    To specify a method name for the functions, use the setFunction function.

    setFunction(cm, unsetMethods, 'MethodName', 'my_$N')

    Input Arguments

    collapse all

    C++ code mapping object, returned by a call to either the coder.mapping.utils.create function or the coder.mapping.api.get function.

    Category of model elements to search for in the model code mappings.

    Example: 'ResetFunctions'

    Name of an entry-point function generated for a model.

    Example: 'my_$N'

    Data Types: char | string

    Output Arguments

    collapse all

    Model elements found, returned as an array or string vector of functions. Each object identifies a model element of the specified category. If you specify additional search criteria, the array or string vector includes objects for model elements of the specified category that meet the additional search criteria.

    Version History

    Introduced in R2021a