Contenido principal

saveChanges

Save changes to data dictionary

Description

saveChanges(dictionaryObj) saves all changes made to a data dictionary dictionaryObj, a Simulink.data.Dictionary object. saveChanges also saves changes made to referenced data dictionaries. The previous states of the target dictionary and its referenced dictionaries are permanently lost.

example

Examples

collapse all

Create a new data dictionary myNewDictionary.sldd and represent the Design Data section with a Simulink.data.dictionary.Section object named dDataSectObj.

myDictionaryObj = Simulink.data.dictionary.create('myNewDictionary.sldd')
dDataSectObj = getSection(myDictionaryObj,'Design Data');
myDictionaryObj = 

  data dictionary with properties:

          DataSources: {0x1 cell}
    HasUnsavedChanges: 0
           NumberOfEntries: 0

Change myNewDictionary.sldd by adding an entry named myNewEntry with value 237. View the HasUnsavedChanges property of myDictionaryObj to confirm a change was made.

addEntry(dDataSectObj,'myNewEntry',237);
myDictionaryObj
myDictionaryObj = 

  Dictionary with properties:

          DataSources: {0x1 cell}
    HasUnsavedChanges: 1
           NumberOfEntries: 1

Save all changes to myNewDictionary.sldd. The HasUnsavedChanges property of myDictionaryObj indicates changes were saved.

saveChanges(myDictionaryObj)
myDictionaryObj
myDictionaryObj = 

  Dictionary with properties:

          DataSources: {0x1 cell}
    HasUnsavedChanges: 0
           NumberOfEntries: 1

Input Arguments

collapse all

Target data dictionary, specified as a Simulink.data.Dictionary object. Before you use this function, represent the target dictionary with a Simulink.data.Dictionary object by using, for example, the Simulink.data.dictionary.create or Simulink.data.dictionary.open function.

Alternatives

  • Save the changes in memory to a data dictionary by using a Simulink.data.DataConnection object function.

    Update the value of a variable in the data dictionary. Then save the change.

    dd = Simulink.data.connect("myDictionary.sldd")
    dd.x = dd.x + 2;
    success = saveChanges(dd)
    
    success = 
    
    logical
        1
    

    Check whether the data dictionary contains unsaved changes.

    dirty = hasUnsavedChanges(dd)
    
    dirty = 
    
    logical
        0
    
  • You can use Model Explorer to save changes to a data dictionary by right-clicking on the dictionary tree node in the Model Hierarchy pane and selecting Save Changes.

Version History

Introduced in R2015a