Main Content

find

Get model elements for the category of model code mappings

    Description

    example

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

    example

    modelElementsFound= find(myCodeMappingObj,category,Name,Value) returns the elements in the model code mappings of the specified category that match specified property and value criteria.

    Examples

    collapse all

    In the model code mappings for model myConfigModel, find model workspace parameters.

    cm = coder.mapping.api.get('myConfigModel');
    inportBlkHandles = find(cm,'ModelParameters');
    

    For model myConfigModel, find Inport blocks that have storage class set to Auto. For each Inport block found, change the storage class setting to Model default.

    cm = coder.mapping.api.get('myConfigModel');
    inportBlkHandles = find(cm,'Inports','StorageClass','Auto');
    setInport(cm,inportBlkHandles,'StorageClass','Model default');
    

    Input Arguments

    collapse all

    Code mapping object returned by a call to function coder.mapping.api.get.

    Example: myCM

    Category of model elements that you search for in the model code mappings.

    Example: 'Inports'

    Name-Value Arguments

    Example: 'Identifier','mp_table1'

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments as Name1,Value1,…,NameN,ValueN. The order of the name and value pair arguments does not matter.

    Data element storage class to include in code mappings search criteria. The name of a predefined storage class or storage class that is defined in the Embedded Coder Dictionary associated with the model. Values that you can specify vary depending on the category that you specify.

    Name that the code generator uses to identify a data element in generated code. Applies to storage classes other than Auto.

    Data Types: char | string

    Output Arguments

    collapse all

    Model elements found, returned as an array or string vector of objects. 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. The object returned for an element depends on the category that you specify.

    CategoryType of Object Returned
    Inports, Outports, and StatesBlock handle
    SignalsPort handle
    DataStoresBlock handle
    ModelParametersModel parameter name
    Introduced in R2020b