Main Content

discardChanges

Discard data in memory and reload from connected data source

Since R2024a

    Description

    discardChanges(connectionObj) discards the data in memory and reloads the data from the connected data source connectionObj. The function returns 1 (true) if the discard was successful, and 0 (false) if the data connection was unable to revert the data from the disk.

    example

    Examples

    collapse all

    Get the value for the variable x in a data dictionary.

    dd = Simulink.data.connect("myDictionary.sldd");
    dd.x 
    
    ans = 
        1

    Update the variable x and get its new value.

    dd.x = dd.x + 2;
    dd.x 
    
    ans = 
        3
    

    Discard the changes to the data dictionary. Variable x is set back to its original value.

    success = discardChanges(dd);
    dd.x
    
    ans = 
        1

    Input Arguments

    collapse all

    Connection to data source, specified as a Simulink.data.DataConnection object.

    Version History

    Introduced in R2024a