View and Revert Changes to 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?.
View and Revert Changes to Dictionary Entries
This example shows how to view unsaved changes to dictionary entries, who made them, and when. You can view changes to entries in any section, including data stored in the Other Data section and configuration sets stored in the Configurations section.
Open the data dictionary linked to this model. Click the model data badge in the bottom left corner of the model, then click the External Data link.
In the Model Explorer Model Hierarchy pane, under the External Data node, select the Design Data node for
In the Contents pane, change
The Status column of these entries changes to
Mod, indicating that they have been modified.
Click the heading of the Status column to sort the entries. Then, select the modified entries, which are indicated by the
Right-click and select Show Changes.
The Comparison Tool appears, displaying changed entries in separate tabs. The tool highlights changed values.
The Comparison Tool does not display changes to the data dictionary property Enable dictionary access to base workspace.
In the Contents pane of the Model Explorer, right-click
zero_threshand select Revert to Saved.
zero_threshto its value at the time of the last save action.
You can merge entries between dictionaries using the Comparison Tool. From the MATLAB desktop, on the Home tab, in the File section, click Compare.
Select the dictionaries to compare and merge.
In the comparison report, select the merge direction for each dictionary entry.
View and Revert Changes to Entire Dictionary
If you store model variables in a data dictionary, you can view and manage the changes that you make while you work. You can use the Comparison Tool to see the changes made to a dictionary, which compares the modified dictionary with the most recent saved version.
When you view the changes to a dictionary, you can choose to discard changes to individual entries or dictionary references, which reverts to the last saved state. You can use this technique to recover entries that you delete in your modified version or dictionary references that you remove.
If you view changes to a dictionary that references other dictionaries, the Comparison Tool also reports changes made to the entries in the referenced dictionaries.
View the example data dictionary
sldemo_fuelsys_ddin Model Explorer.
dictionary = Simulink.data.dictionary.open('sldemo_fuelsys_dd.sldd'); show(dictionary)
The dictionary contains entries that are defined in several referenced dictionaries, including
Make some changes to
section = getSection(dictionary,'Design Data'); deleteEntry(section,'PressVect'); entry = getEntry(section,'min_throt'); entryValue = getValue(entry); entryValue.DataType = 'int8'; entryValue.Value = 4; setValue(entry,entryValue);
In the Model Hierarchy pane of Model Explorer, right-click the node
sldemo_fuelsys_ddand select Show Changes.
The Comparison Tool displays the changes made to the dictionary.
In the table at the top of the report, click compare in the Change Summary column of the row that corresponds to the entry
A new tab shows the changes made to
min_throt. The script changed the parameter data type from
int8and the parameter value from
Click the tab that shows the changes made to the dictionary. In the Action column of the row that corresponds to the entry
min_throt, click Revert to Saved.
The entry reverts to the definition from the last saved version of the dictionary.
The remaining row in the report shows that the script deleted the entry
PressVect, which was defined in the referenced dictionary
sldemo_fuelsys_dd_controller. Click Recover from Saved, which recovers the entry in the referenced dictionary.
The table Dictionary references in sldemo_fuelsys_dd.sldd shows that the script removed the reference to the dictionary
sldemo_fuelsys_dd_plant. In the Action column, click Recover Reference.
The report shows that there are no more unsaved changes to