Main Content


Create Embedded Coder Dictionary and coder.Dictionary object

Since R2019b



coderDict = coder.dictionary.create(sourceName) creates an Embedded Coder® Dictionary in the model or Simulink® data dictionary identified by sourceName. The function returns a coder.Dictionary object that represents the new Embedded Coder Dictionary. The Embedded Coder Dictionary uses the data interface configuration type.

When the source model or data dictionary already has an Embedded Coder Dictionary, use to access the coder.Dictionary object. An Embedded Coder Dictionary is created when you open a model in the Embedded Coder app or when you open the Embedded Coder Dictionary dialog box for a model or a data dictionary.


coderDict = coder.dictionary.create(sourceName,interfaceType) creates an Embedded Coder Dictionary that uses the specified code interface type. You can create an Embedded Coder Dictionary that uses either the data interface configuration or service interface configuration by using this syntax. (since R2023b)


collapse all

Create a data dictionary.

dataDictionary ="DataDictionary.sldd");

Create an Embedded Coder Dictionary in the data dictionary.

coderDictionary = coder.dictionary.create(dataDictionary);
coderDictionary = 

  Dictionary with Sections:

                    StorageClasses: [1×1 coder.dictionary.Section]
                    MemorySections: [1×1 coder.dictionary.Section]
    FunctionCustomizationTemplates: [1×1 coder.dictionary.Section]

Create a data dictionary to store the Embedded Coder Dictionary.

dataDictionary ="DataDictionary.sldd");

Create an Embedded Coder Dictionary in the data dictionary. Specify the service interface configuration type.

coderDictionary = coder.dictionary.create(dataDictionary,"ServiceInterface");
coderDictionary = 

  Dictionary with properties and Sections:

               ServicesHeaderFileName: 'services.h'
                    InitTermFunctions: [1×1 coder.dictionary.Section]
           PeriodicAperiodicFunctions: [1×1 coder.dictionary.Section]
               DataReceiverInterfaces: [1×1 coder.dictionary.Section]
                 DataSenderInterfaces: [1×1 coder.dictionary.Section]
               DataTransferInterfaces: [1×1 coder.dictionary.Section]
                      TimerInterfaces: [1×1 coder.dictionary.Section]
            ParameterTuningInterfaces: [1×1 coder.dictionary.Section]
    ParameterArgumentTuningInterfaces: [1×1 coder.dictionary.Section]
                MeasurementInterfaces: [1×1 coder.dictionary.Section]
             SubcomponentInitTermFunctions: [1×1 coder.dictionary.Section]
    SubcomponentPeriodicAperiodicFunctions: [1×1 coder.dictionary.Section]
               SharedUtilityFunctions: [1×1 coder.dictionary.Section]
                              InternalData: [1×1 coder.dictionary.Section]
                                 Constants: [1×1 coder.dictionary.Section]
                       StorageClasses: [1×1 coder.dictionary.Section]
                   DataMemorySections: [1×1 coder.dictionary.Section]
               FunctionMemorySections: [1×1 coder.dictionary.Section]

Now you can access the sections of the dictionary and use the sections to add and edit service interface definitions.

Input Arguments

collapse all

Name of target model file or data dictionary, specified as a character vector, string scalar, or object.

  • A model must be loaded (for example, by using load_system) or open.

    You do not need to specify the .slx file extension.

  • A dictionary must be open in the Model Explorer, in the current folder, or on the MATLAB® path.

    You must specify the .sldd file extension.

Example: "myLoadedModel"

Example: "myDictionary.sldd"

Data Types: char

Since R2023b

Code interface configuration type, specified as either "DataInterface" or "ServiceInterface". If sourceName is a Simulink model, the interfaceType must be "DataInterface".

Choose the code interface configuration type by considering how you will deploy the generated code:

  • Data interface configuration — The code generator creates a program intended to run on the target device. The generated code uses the data interfaces that you define.

  • Service interface configuration — The code generator creates an algorithm that you intend to deploy within a larger application. The platform middleware calls the algorithm code and provides the services for the target device. The generated code calls the services according to your definitions in the service interface configuration. To create a service interface configuration, you must use an Embedded Coder Dictionary that is stored in a Simulink data dictionary.

Example: "ServiceInterface"

Data Types: char

Output Arguments

collapse all

Newly created Embedded Coder Dictionary, returned as a coder.Dictionary object.

Version History

Introduced in R2019b

expand all