Main Content

Import and Export Dictionary Data

A Simulink® data dictionary permanently stores model data including MATLAB® variables, data objects, and data types. For basic information about data dictionaries, see What Is a Data Dictionary?.

Import Data to Dictionary from File

You can import data from a MATLAB file or MAT-file to a data dictionary using the Model Explorer window. Import variables and data objects that are used by a model during simulation to the Design Data section of a dictionary. Import variables and objects that you want to store with a model, but that are not used by the model during simulation, to the Other Data section of a dictionary.

Import Design Data from File

This example shows how to import design data from a file into the Design Data section of a dictionary.

  1. In the Simulink Editor, in the Modeling tab, click Model Explorer to open the Model Explorer.

  2. Select File > Open. Then browse to an existing dictionary.

  3. In the Model Hierarchy pane, right-click the Design Data section of the dictionary and select Import from File. Then browse to and select the MAT-file or MATLAB file that contains the data to import.

    Context menu of Design Data node displayed with Import From File menu item selected

    Design data from the MAT-file populate the dictionary. Data appear with DataSource set to the name of the dictionary.

    Model Explorer with Design Data node selected and imported data displayed in the Contents pane

    If you import from the same MAT-file again, Simulink only imports changed or new entries into the dictionary.

Import Other Data from File

This example shows how to import data from a file into the Other Data section of a data dictionary. Use this section to store reference information that is not used by Simulink during simulation, such as data that describe physical equipment and processes that are represented by your model.

  1. In the Simulink Editor, in the Modeling tab, click Model Explorer to open the Model Explorer.

  2. Select File > Open. Then browse to an existing dictionary.

  3. In the Model Hierarchy pane, right-click the dictionary node and select Show Empty Sections. Model Explorer reveals the Other Data and Configurations sections of the dictionary, even if they are empty, in addition to the Design Data section.

    Context menu of a data dictionary node displayed with Show Empty Sections menu item selected

  4. In the Model Hierarchy pane, right-click the Other Data section of the dictionary and select Import from File. Then browse to and select the MAT-file or MATLAB file that contains the reference data to import.

    Context menu of Other Data node displayed with Import From File menu item selected

    Data from the MAT-file populate the Other Data section of the dictionary. Data appear with DataSource set to the name of the dictionary.

    View of Model Explorer. In the Model Hierarchy pane, the Other Data node of a data dictionary is selected. In the Contents pane, imported data is displayed.

    If you import from the same MAT-file again, Simulink only imports changed or new entries into the dictionary.

Export Design Data from Dictionary

This example shows how to export model design data from a data dictionary into a MAT-file or MATLAB script.

  1. In the Simulink Editor, in the Modeling tab, click Model Explorer to open the Model Explorer.

  2. Open a data dictionary using File > Open Data Dictionary.

  3. In the Model Hierarchy pane, expand the dictionary node and select Design Data > Export to File. Then save the design data to a MAT-file or MATLAB script.

    Context menu of Design Data node displayed with Export to File menu item selected

The dictionary does not export enumerated data types (which are stored as Simulink.data.dictionary.EnumTypeDefinition objects). To transfer or copy an enumerated type from one dictionary to another, use the Model Explorer to cut or copy and paste the object.

Related Topics