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 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 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

    The type of code mappings to return for the specified model. 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, SimulinkCoderC or EmbeddedCoderC. If a code mapping of the specified type does not exist, Simulink returns an error.

    Example: 'SimulinkCoderC'

    Output Arguments

    collapse all

    The model code mappings, returned as a CodeMapping object.

    Introduced in R2020b