Main Content

coder.mapping.api.get

Get code mappings for model

Since R2020b

    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 and functions 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 the model in a coder app, you can create a code mappings object with a call to coder.mapping.util.create. For example, see Create and Use Code Mappings for Model

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

    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

    Assuming that the model has a code mappings object, use the coder.mapping.api.get function to get the active code mappings object of the model myConfigModel. Then use the getInport function to retrieve the storage class of input port In1 of the model. Use the code mappings object as the first input argument of getInport.

    myCodeMappingObj = coder.mapping.api.get("myConfigModel");
    myInputStorageClass = getInport(myCodeMappingObj,"In1","StorageClass")
    

    Use the coder.mapping.util.create function to create a code mappings object for the model myConfigModel. Then use the getInport function to retrieve the storage class of input port In1 of the model. Use the newly created code mappings object as the first input argument to getInport.

    myCodeMappingObj = coder.mapping.utils.create("myConfigModel");
    myInput = getInport(myCodeMappingObj,"In1","StorageClass")
    

    Assuming that the model has a Simulink Coder C code mappings object, use the coder.mapping.api.get function to get this code mapping object. The first argument to the function is the model name, and the second argument is the type of code mapping object you want to get. Then use the getInport function to retrieve the storage class of input port In1 of the model.

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

    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.CodeMappingCPPSimulink modelEmbeddedCoderCPP
    coder.mapping.api.CoderDictionarySimulink data dictionaryN/A

    Version History

    Introduced in R2020b