Main Content

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.

  1. Open the sldemo_fuelsys_dd_controller model.

    openExample('simulink_automotive/UseDDForFuelContSysExample','supportingfile','sldemo_fuelsys_dd_controller')

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

  3. In the Model Explorer Model Hierarchy pane, under the External Data node, select the Design Data node for sldemo_fuelsys_dd_controller.

  4. In the Contents pane, change st_range to 0.0002 and zero_thresh to 200.

    The Status column of these entries changes to Mod, indicating that they have been modified.

  5. Click the heading of the Status column to sort the entries. Then, select the modified entries, which are indicated by the Mod status.

    View of Model Explorer. In the Model Hierarchy pane, the Design Data node of data dictionary is selected. In the Contents pane, two modified entries in the data dictionary are selected. The context menu for the entries has the Show Changes menu item selected.

  6. Right-click and select Show Changes.

    The Comparison Tool appears, displaying changed entries in separate tabs. The tool highlights changed values.

    Comparison Tool dialog box with the Comparison tab open on the toolstrip. The Comparison tab has a tab for each of the changed entries. The changed values are highlighted.

    Note

    The Comparison Tool does not display changes to the data dictionary property Enable dictionary access to base workspace.

  7. In the Contents pane of the Model Explorer, right-click zero_thresh and select Revert to Saved.

    Simulink reverts zero_thresh to its value at the time of the last save action.

  8. You can merge entries between dictionaries using the Comparison Tool. From the MATLAB desktop, on the Home tab, in the File section, click Compare.

  9. Select the dictionaries to compare and merge.

    Select Files or Folders for Comparison dialog box. Two data dictionaries are selected for comparison. The Comparison type is set to "Comparison of files with extension (.sldd)".

  10. In the comparison report, select the merge direction for each dictionary entry.

    A dictionary file comparison report. Each row in the report compares a variable entry in one dictionary to the same variable in the other dictionary. Buttons at the end of the row allow you to select the merge direction for the 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.

  1. View the example data dictionary sldemo_fuelsys_dd in 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 sldemo_fuelsys_dd_controller and sldemo_fuelsys_dd_plant.

  2. Make some changes to sldemo_fuelsys_dd.

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

  3. In the Model Hierarchy pane of Model Explorer, right-click the node sldemo_fuelsys_dd and select Show Changes.

    The Comparison Tool displays the changes made to the dictionary.

    Comparison tool that displays changes to a data dictionary. The first column displays saved entries in the data dictionary. The second column displays unsaved changes to those entries. The third column displays a change summary, a last modified timestamp, and a clickable action you can take to recover or revert changes. Below this table is a table of Dictionary references The first column displays saved references. The second column displays unsaved changes. The third column displays a change summary and a clickable action you can take to recover a reference.

  4. In the table at the top of the report, click compare in the Change Summary column of the row that corresponds to the entry min_throt.

    A new tab shows the changes made to min_throt. The script changed the parameter data type from auto to int8 and the parameter value from 3 to 4.

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

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

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

Related Topics