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.
In the Simulink Editor, in the Modeling tab, click Model Explorer to open the Model Explorer.
Select File > Open. Then browse to an existing dictionary.
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.
Design data from the MAT file populate the dictionary. Data appear with DataSource set to the name of the dictionary.
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.
In the Simulink Editor, in the Modeling tab, click Model Explorer to open the Model Explorer.
Select File > Open. Then browse to an existing dictionary.
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.
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.
Data from the MAT file populate the Other Data section of the dictionary. Data appear with DataSource set to the name of the dictionary.
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.
In the Simulink Editor, in the Modeling tab, click Model Explorer to open the Model Explorer.
Open a data dictionary using File > Open Data Dictionary.
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.
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.