Main Content

coder.mapping.api.get

Get code mappings for model

    Description

    example

    myCodeMappingObj = coder.mapping.api.get(model) returns the active code mappings for the specified model as object myCodeMappingObj. Code mappings associate model data elements with configurations for code generation. If a model has multiple code mappings, the active code mappings are the mappings associated with the active system target file.

    If code mappings do not exist, Simulink® returns an error. Simulink creates a code mappings object when you open a model in a coder app. If you have not opened a model in a coder app, you can create a code mappings object with a call to coder.mapping.util.create.

    myCodeMappingObj = coder.mapping.api.get(dictionary) returns the active code mappings for the specified dictionary as object myCodeMappingObj. Code mappings associate data elements in the data dictionary with configurations for code generation.

    If code mappings do not exist, Simulink returns an error. Simulink creates a code mappings object when you open a model in a coder app. If you have not opened a model in a coder app, you can create a code mappings object with a call to coder.mapping.util.create.

    example

    myCodeMappingObj = coder.mapping.api.get(model,codeMappingType) returns the code mappings for your model that correspond to the specified code mapping type as object myCodeMappingObj. Code mappings enable you to associate a model with code generation configurations for C rapid prototyping (Simulink Coder™ and C language) and C production (Embedded Coder® and C language) platforms. The code mappings type specifies your platform of interest. If a code mapping of the specified type does not exist, Simulink returns an error.

    Examples

    collapse all

    For model myConfigModel, return the code mappings to object myCodeMappingObj. Specify the returned object as the first argument in subsequent calls to other code mappings API functions. This example specifies the returned object in a call to getInport.

    myCodeMappingObj = coder.mapping.api.get('myConfigModel');
    myInput = getInport(myCodeMappingObj, 'In1', 'myConfigModel');
    

    In this example, for model myConfigModel, create the code mappings object myCodeMappingObj by calling coder.mapping.util.create. Then, return the object with a call to coder.mapping.api.get. This example specifies the returned object in a call to getInport.

    myCodeMappingObj = coder.mapping.utils.create('myConfigModel');
    cm = coder.mapping.api.get(myCodeMappingObj);
    myInput = getInport(cm, 'In1', 'myConfigModel');

    For model myConfigModel, return the Simulink Coder C language code mappings to object mySCCodeMappingObj. Specify the returned object as the first argument in subsequent calls to other code mappings API functions. This example specifies the returned object in a call to getInport.

    mySCCodeMappingObj = coder.mapping.api.get('myConfigModel','SimulinkCoderC');
    myInput = getInport(mySCCodeMappingObj, 'In1', 'myConfigModel');

    Input Arguments

    collapse all

    Model for which to return code mappings object, specified as a handle or a character vector or string scalar representing the model name. The model must be loaded (for example, by using load_system) or open. Omit the .slx file extension.

    Example: 'myConfigModel'

    Data Types: char | string | model_handle

    Data dictionary for which to return code mappings object, specified as a character vector or string scalar representing the dictionary name.

    Example: 'exCodeDefs.sldd'

    Data Types: char | string

    The type of code mappings to return for the specified model or dictionary. Code mappings enable you to associate a model with code generation configurations for C rapid prototyping (Simulink Coder and C language) and C and C++ production (Embedded Coder and C and C++ language) platforms. The code mappings type specifies your platform of interest, SimulinkCoderC, EmbeddedCoderC, or EmbeddedCoderCPP. If a code mapping of the specified type does not exist, Simulink returns an error.

    Example: 'SimulinkCoderC'

    Output Arguments

    collapse all

    The model or dictionary code mappings, returned as a CodeMapping object, a CodeMappingCPP object, or a CoderDictionary object.

    OutputInput ObjectCode Mapping Type
    coder.mapping.api.CodeMappingSimulink modelSimulinkCoderC or EmbeddedCoderC
    coder.mapping.api.CodeMappingCPP (Embedded Coder)Simulink modelEmbeddedCoderCPP
    coder.mapping.api.CoderDictionarySimulink data dictionaryN/A

    Introduced in R2020b